Thursday, 15 September 2011

Different Elasticsearch results for the same query -



Different Elasticsearch results for the same query -

i've setup elasticsearch 1 cluster á 4 nodes. number of shards per index: 1; number of replicas per index: 3

when phone call simple query next 1 multiple times different results (different total hits , different top 10 documents):

http://localhost:9200/index_name/_search?q=term

different info on each shard? have shards date. can do?

this result of /_cluster/health:

{ "cluster_name" : "secret", "status" : "green", "timed_out" : false, "number_of_nodes" : 4, "number_of_data_nodes" : 4, "active_primary_shards" : 24, "active_shards" : 96, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }

as temporary solution rebuild index through ruby gem tire: modelname.rebuild_index

but need long-term solution.

this because don't have specified sort order , size. every time query random first 10 records default size result set elasticsearch server 10.

you can add together sorting in next way curl,

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

check here for more info specially from , size sort used pagination.

update:

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

elasticsearch

No comments:

Post a Comment