Hello,World

企业搜索不精确达不到预期值

Elasticsearch | 作者 BNingliu | 发布于2020年10月14日 | 阅读数:1167

{
"_index" : "company",
"_type" : "company_doc",
"_id" : "22140090",
"_score" : 11.854989,
"_source" : {
"name" : "新泰市中新师大酒店"
}
},
{
"_index" : "company",
"_type" : "company_doc",
"_id" : "74034109",
"_score" : 11.776882,
"_source" : {
"name" : "新乡新大新恒欣物业中心"
}
},
{
"_index" : "company",
"_type" : "company_doc",
"_id" : "69759229",
"_score" : 11.539751,
"_source" : {
"name" : "大丰市大中镇创新网吧"
}
},


GET /company/_search/
{
"query": {
"match": {
"name": "新中大"
}
}

}
想让包含新中大三个字的排在前面
已邀请:

FFFrp

赞同来自:

GET /company/_search/
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "新中大"
          }
        }
      ],
      "should": [
        {
          "match": {
            "name": {
              "query": "新中大",
              "minimum_should_match": "100%",
              "boost": 1
            }
          }
        }
      ]
    }
  }
}
增加一个should加权,调整boost控制增加的分数

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

注意:match_phrase 的使用

要回复问题请先登录注册