Embedded ES used for unit testing not returning deterministic results

Hi:
I am using ES 2.3.4 and firing up an embedded ES instance to perform unitTesting
(the test scenario is to query for a string against a custom analyzed field and make sure the results returned are in the same order every time. )

  1. I fire up the ES instance in the @BEfore section of the unItTest, use the Node Client to create Index, and populate the index with content.

  2. I end the bulk loading with the following two commands:
    client.admin().indices().prepareFlush(indexName).setForce(true).execute().get();
    client.admin().indices().prepareRefresh(indexName).execute().get();

  3. I execute my query sorting first by score and then by field(not_analyzed).

The result set is different typically from the 4 document that is returned. (the top 3 sometimes 4 documents are the same. However, the scores that are assigned to the documents (all result documents) are different every time.

Is this a known issue with embedded ES or am I missing a setting on my embedded ES instance so that I get back consistent results.

Thanks for the assistance

I guess you have multiple shards. Have a look here:
https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-is-broken.html

1 Like

Excellent, I had read the article but did not connect my issue with the post. Thanks much

Ramdev