ElasticSearch default scoring mechanism

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 23:53:58

The default scoring is the DefaultSimilarity algorithm in core Lucene, largely documented here. You can customize scoring by configuring your own Similarity, or using something like a custom_score query.

The odd score variation in the first five results shown seems small enough that it doesn't concern me much, as far as the validity of the query results and their ordering, but if you want to understand the cause of it, the explain api can show you exactly what is going on there.

The score variation is based on the data in a given shard (like you suspected). By default ES uses a search type called 'query then fetch' which, sends the query to each shard, finds all the matching documents with scores using local TDIFs (this will vary based on data on a given shard - here's your problem).

You can change this by using 'dfs query then fetch' search type - prequery each shard asking about term and document frequencies and then sends a query to each shard etc..

You can set it in the url

$ curl -XGET '/index/type/search?pretty=true&search_type=dfs_query_then_fetch' -d '{
  "from": 0,
  "size": 300,
  "explain": true,
  "query": {
    "match": {
      "Name": {
        "query": "ExampleName"
      }
    }
  }
}' 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!