我观察到连接到Elasticsearch集群中的不同节点时得到的结果是变化的,尽管我将preference参数设置为相同的自定义字符串。对于前。以下两个查询返回的结果不同(10.21.160.54具有主要共享,而10.21.160.56具有副本)。
$ curl 'http://10.21.160.54:9200/automation-lucene.qa_en_18_12_query/esmessage/_search?size=25&preference=xyzabc123&timeout=10s' -d '{"query":{"filtered":{"query":{"bool":{"must":[{"match_all":{}},{"match":{"privacyLevel":{"query":"public","operator":"and"}}},{"match":{"is_root":{"query":"true","operator":"and"}}},{"match":{"entity-type.key":{"query":"message","operator":"and"}}}]}},"filter":{"bool":{"must_not":{"terms":{"board_id":["@review","@media@public","@media@private"]}}}}}},"sort":[{"popularity":"desc"}]}'
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":324,"max_score":null,"hits":[{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"903","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"904","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"906","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"918","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"919","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"917","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"916","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"915","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"896","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"897","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"898","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"901","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"902","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"899","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"910","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"913","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"914","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"935","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"929","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"931","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"932","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"930","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"895","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"894","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"908","_score":null,"sort":[0.0]}]}}
$ curl 'http://10.21.160.56:9200/automation-lucene.qa_en_18_12_query/esmessage/_search?size=25&preference=xyzabc123&timeout=10s' -d '{"query":{"filtered":{"query":{"bool":{"must":[{"match_all":{}},{"match":{"privacyLevel":{"query":"public","operator":"and"}}},{"match":{"is_root":{"query":"true","operator":"and"}}},{"match":{"entity-type.key":{"query":"message","operator":"and"}}}]}},"filter":{"bool":{"must_not":{"terms":{"board_id":["@review","@media@public","@media@private"]}}}}}},"sort":[{"popularity":"desc"}]}'
{"took":2,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":324,"max_score":null,"hits":[{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"935","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"937","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"938","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"936","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"895","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"894","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"941","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"942","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"918","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"925","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"919","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"920","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"917","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"916","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"929","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"931","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"932","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"930","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"926","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"896","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"908","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"903","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"907","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"905","_score":null,"sort":[0.0]},{"_index":"automation-lucene.qa_en_18_12","_type":"esmessage","_id":"902","_score":null,"sort":[0.0]}]}}
但是,如果我将首选项设置为_primary,则结果是一致的。
我正在使用Elasticsearch 1.7。有人对使用某些自定义字符串时为什么不应用首选项有任何想法吗?首选项参数仅在连接到同一节点时有效吗?