ElasticSearch default scoring mechanism

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"
      }
    }
  }
}' 

Great explanation in ElasticSearch documentation:

  • What is relevance: https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html

  • Theory behind relevance scoring: https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html


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.