不为失败找理由,要为成功找方法。

es 7.2 同义词安装已经生效,但是搜索时不生效

Elasticsearch | 作者 acclea | 发布于2021年02月04日 | 阅读数:1672

分析接口
/_index_test/_analyze

{
  "analyzer": "ik_syno_smart",
  "text": "jingji"
}
返回

{
    "tokens": [
        {
            "token": "经济",
            "start_offset": 0,
            "end_offset": 6,
            "type": "SYNONYM",
            "position": 0
        }
    ]
}
 
 
搜索时指定  analyzer  为同义词时无法查询到结果
/_index_test/_search

{
  "query": {
    "bool": {
        "filter":{"term":{"status":1}},
        "should": [
            { "multi_match": 
                {
                    "query":"jingji",
                    "analyzer":"standard",
                    "type":"best_fields",
                    "fields":["article_title^999991", "article_kw^9999",  "article_des", "article_intro", "article_tag^9999", "article_cont"]
                }
            }
      ]
    }
  },
  "min_score":1,
  "size":2
}
 
但是,如果不指定 analyzer 或者 指定为 standard ,搜索词 为  经济  ,就可以查询到相关的内容
 
求大佬,救救这个菜鸡
 
已邀请:

medcl - 今晚打老虎。

赞同来自:

/_index_test/_analyze

{
"analyzer": "ik_syno_smart",
"text": "经济"
}
看看这个返回的内容是啥。

要回复问题请先登录注册