Different Elasticsearch results for the same query

后端 未结 3 1835
太阳男子
太阳男子 2021-01-11 12:33

I\'ve setup Elasticsearch with 1 cluster á 4 nodes. Number of shards per index: 1; Number of replicas per index: 3

When I call a simple query like the following one

3条回答
  •  甜味超标
    2021-01-11 13:04

    This is because you don't have specified sort order and size. So every time you query you get random first 10 records as default size for result set by elasticsearch server is 10.

    You can add sorting in following way with curl,

    curl -XPOST 'localhost:9200/_search' -d '{
     "query" : {
       ...
      },
       "sort" : [
         {"price" : {"order" : "asc", "mode" : "avg"}}
       ]
    }'
    

    Check here for for more info specially from and size with sort which is most mostly used for pagination.

    update:

    Though default sort is score DESC sometime it not works when records don't have relevant _score, as per http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_sorting.html#_sorting

提交回复
热议问题