elasticsearch - ElasticSearch评分问题

标签 elasticsearch indexing nosql

我正在尝试找出ElasticSearch在按分数对结果进行排名中使用的逻辑。

我总共有4个索引。我正在查询所有索引的术语。我正在使用的查询如下-

GET /_all/static/_search
{
  "query": {
    "match": {
      "name": "chinese"
    }
  }
}

我得到的(部分)响应如下:
    {
   "took": 17,
   "timed_out": false,
   "_shards": {
      "total": 40,
      "successful": 40,
      "failed": 0
   },
   "hits": {
      "total": 6,
      "max_score": 2.96844,
      "hits": [
         {
            "_shard": 1,
            "_node": "Hz9L2DZ-ShSajaNvoyU8Eg",
            "_index": "restaurant",
            "_type": "static",
            "_id": "XecLkyYNQWihuR2atFc5JQ",
            "_score": 2.96844,
            "_source": {
               "name": "Just Chinese"
            },
            "_explanation": {
               "value": 2.96844,
               "description": "weight(name:chinese in 1) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 2.96844,
                     "description": "fieldWeight in 1, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0"
                              }
                           ]
                        },
                        {
                           "value": 4.749504,
                           "description": "idf(docFreq=3, maxDocs=170)"
                        },
                        {
                           "value": 0.625,
                           "description": "fieldNorm(doc=1)"
                        }
                     ]
                  }
               ]
            }
         },
         {
            "_shard": 1,
            "_node": "Hz9L2DZ-ShSajaNvoyU8Eg",
            "_index": "restaurant",
            "_type": "static",
            "_id": "IAUpkC55ReySjvl9Xr5MVw",
            "_score": 2.96844,
            "_source": {
               "name": "The Chinese Hut"
            },
            "_explanation": {
               "value": 2.96844,
               "description": "weight(name:chinese in 5) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 2.96844,
                     "description": "fieldWeight in 5, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0"
                              }
                           ]
                        },
                        {
                           "value": 4.749504,
                           "description": "idf(docFreq=3, maxDocs=170)"
                        },
                        {
                           "value": 0.625,
                           "description": "fieldNorm(doc=5)"
                        }
                     ]
                  }
               ]
            }
         },
         {
            "_shard": 2,
            "_node": "Hz9L2DZ-ShSajaNvoyU8Eg",
            "_index": "cuisine",
            "_type": "static",
            "_id": "6",
            "_score": 2.7047482,
            "_source": {
               "name": "Chinese"
            },
            "_explanation": {
               "value": 2.7047482,
               "description": "weight(name:chinese in 1) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 2.7047482,
                     "description": "fieldWeight in 1, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0"
                              }
                           ]
                        },
                        {
                           "value": 2.7047482,
                           "description": "idf(docFreq=1, maxDocs=11)"
                        },
                        {
                           "value": 1,
                           "description": "fieldNorm(doc=1)"
                        }
                     ]
                  }
               ]
            }
         },

我的问题是-我了解 flex 搜索会以较高的分数对待较小的值,那么为什么餐厅索引中的“仅中文”和“中式小屋”这样的结果为什么排在美食的最佳匹配“中国”之上?指数?据我所知,在将这些文档插入索引时,我没有使用任何特殊的分析器或任何工具。一切都是默认的。

我缺少什么,如何得到预期的结果?

最佳答案

计算分数的重要参数之一是inverse document frequency(IDF)。默认情况下,elasticsearch的每个碎片都会尝试根据本地IDF估计全局IDF。当您有很多相似的记录均匀分布在各个分片上时,它就可以工作。但是,当您只有很少的记录或将多个分片的结果与非常不同的记录类型(美食名称和餐馆名称)组合在一起时,估计IDF可能会产生奇怪的结果。解决此问题的方法是使用elasticsearch的dfs_query_then_fetch搜索模式。

顺便说一句,为了了解elasticsearch如何计算分数,您可以在搜索请求中或url上使用explain参数。因此,当您询问有关计分的问题时,当您为输出提供解释设置为true时,它会有所帮助。

关于elasticsearch - ElasticSearch评分问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23041758/

相关文章:

database - ScyllaDB 中多个压缩重叠的可能性是多少?

java - Cassandra 0.7.4 - 使用 Java,如何为请求关联键空间?

java - 无法让 findAll 在 Elasticsearch 中工作

sql-server - 生成数据库中所有索引的脚本

mysql - 索引的 DO 和 DONT

python - 如何在 Python 中将多个项目从一个列表移动到另一个列表

lucene - ElasticSearch 映射和相关对象

elasticsearch - ElasticSearch Analyzer:有没有办法删除索引中出现的相同单词?

elasticsearch - 什么 shasum : elasticsearch-5. 0.0.deb.sha1 : no properly formatted SHA1 checksum lines found means?

maven - 无法运行ElasticSearch测试