1
votes

I have cluster elasticsearch 6.3.2 of 3 nodes: master and 2 data node.I make a request on my index and the result order can be in three different states

if i do some request from kibana:

  • GET index/_search?preference=node1 - one sort order
  • GET index/_search?preference=node2 - another sort order
  • GET index/_search - it can be three states of the sort order

request body is always constant

{
    "from": 0,
    "size": 30,
    "query": {...},
    "sort": [
        {"_score": {"order": "desc"}}, 
        {"_script": {
                "script": {
                    "source": "long code = doc[\"test\"].value; 
                    if(code== 0){return 4;} 
                    if(code== 1){return 2;} 
                    if(code== 2){return 1;} 
                    else return code;",
                    "lang": "painless"
                },
                "type": "string",
                "order": "desc"
            }
        }, 
        {"test1": {"order": "desc"}}, 
        {"test2": {"order": "asc"}}
    ]
    "highlight": {...}
}

i expect the result order be always constant , but it does not

1

1 Answers

0
votes

This is a known issue and happens due to bouncing results, And this can be avoided by always using the same shards for the same user, which can be done by setting the preference parameter to an arbitrary string like the user’s session ID. As suggested in the official Elasticsearch documentation and we also avoided it using preference param in our production.