Well,不要刷屏了

score好像计算不对

Elasticsearch | 作者 hezhiqiang | 发布于2019年09月20日 | 阅读数:1131

我的搜索词是“牛津树第一阶Oxford Reading Tree Stage 1”,结果“Oxford Reading Tree Stage 1”排在了“牛津树第一阶Oxford Reading Tree Stage 1”前面,有点不解,明明后面的是完全匹配,字段的配置是这样的:
      "title": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_smart"
      }
已邀请:

rochy - rochy_he

赞同来自: rolyPolyToy

"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
 
这两个用的分词器不同,所以并不是完全匹配,建议使用 analyze api 看一下结果

hezhiqiang

赞同来自:

网上说建议这样配置分词器...

Ombres

赞同来自:

explain:true,查一下评分详情吧

doom

赞同来自:

你的查询语句是什么,一般匹配多的评分高,排在前面。我的做了个简单的测试,就OK,没有出现你的情况;
PUT mls
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"text":{
"type": "text",
"index": true,
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
}
}
}
}

PUT /mls/_doc/1
{
"text":"Oxford Reading Tree Stage 1"
}

PUT /mls/_doc/2
{
"text":"牛津树第一阶Oxford Reading Tree Stage 1"
}

GET /mls/_search
{
"query": {
"match": {
"text": "牛津树第一阶Oxford Reading Tree Stage"
}
}
}

结果:
{
"took" : 642,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 2.4351532,
"hits" : [
{
"_index" : "mls",
"_type" : "_doc",
"_id" : "2",
"_score" : 2.4351532,
"_source" : {
"text" : "牛津树第一阶Oxford Reading Tree Stage 1"
}
},
{
"_index" : "mls",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.8614388,
"_source" : {
"text" : "Oxford Reading Tree Stage 1"
}
}
]
}
}
 
 

要回复问题请先登录注册