# Java client version upgrade causing issues

**URL:** <https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531>\
**Category:** Elasticsearch\
**Created:** [August 17, 2015, 5:32pm UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531 "2015-08-17T17:32:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Sadashivamur](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@Pradeep\_Sadashivamur](https://discuss.elastic.co/u/Pradeep_Sadashivamur)\
**Post date:** [August 17, 2015, 5:32pm UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531/1 "2015-08-17T17:32:00Z")

</div>

I have upgraded Java client from 1.3.1 version to 1.3.4 but the order of search results are not what I was expecting (in a random order). I tried with many times reverting back and forth the version. All good until 1.3.2 version but after 1.3.3 the search result oder is not same as the search result order of 1.3.2. I have gone through the release notes doesn't give a clue.

Eg:

INDEX:  
curl -XPUT '[http://localhost:9200/default-index/DummyObject/1](http://localhost:9200/default-index/DummyObject/1)' -d '{ "id" : "first", "name" : "INDIVIDUAL" }'  
curl -XPUT '[http://localhost:9200/default-index/DummyObject/2](http://localhost:9200/default-index/DummyObject/2)' -d '{ "id" : "second", "name" : "individual" }'  
curl -XPUT '[http://localhost:9200/default-index/DummyObject/3](http://localhost:9200/default-index/DummyObject/3)' -d '{ "id" : "third", "name" : "IndIVIDUAL" }'

SEARCH:  
curl -XGET '[http://localhost:9200/default-index/DummyObject/\_search](http://localhost:9200/default-index/DummyObject/_search)' -d '{"query":{"match\_all":{}}}'

The result until version 1.3.2 is "first, second and third" but after version 1.3.3 it is "third, first and second". I was expecting / want the result to be "first, second and third". Please help. Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 17, 2015, 5:52pm UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531/2 "2015-08-17T17:52:44Z")

</div>

> [@Pradeep\_Sadashivamur](#):
>
> INDEX:curl -XPUT '[http://localhost:9200/default-index/DummyObject/1](http://localhost:9200/default-index/DummyObject/1)' -d '{ "id" : "first", "name" : "INDIVIDUAL" }'curl -XPUT '[http://localhost:9200/default-index/DummyObject/2](http://localhost:9200/default-index/DummyObject/2)' -d '{ "id" : "second", "name" : "individual" }'curl -XPUT '[http://localhost:9200/default-index/DummyObject/3](http://localhost:9200/default-index/DummyObject/3)' -d '{ "id" : "third", "name" : "IndIVIDUAL" }'
> 
> SEARCH:curl -XGET '[http://localhost:9200/default-index/DummyObject/\_search](http://localhost:9200/default-index/DummyObject/_search)' -d '{"query":{"match\_all":{}}}'
> 
> The result until version 1.3.2 is "first, second and third" but after version 1.3.3 it is "third, first and second". I was expecting / want the result to be "first, second and third". Please help. Thanks

So the sort order of `match_all` is pretty undefined. Its just whatever order it was read back in the index and whatever order the coordinating node decided to merge the results. In this case I'm not surprised that the order changed. I'm more surprised that it was consistent for you for so long.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 17, 2015, 5:54pm UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531/3 "2015-08-17T17:54:10Z")

</div>

If you want to `sort` your results, then you have to add a sort.

You are running a `match_all` here with default sorting by `_score`. Each score is `1` so you can not say that you expect 1 before 2 or 2 before 3.

It depends. May be they can come back in the order you expect if you have only one shard, but I would definitely not rely on that and add a proper sort.

My cents.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Sadashivamur](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@Pradeep\_Sadashivamur](https://discuss.elastic.co/u/Pradeep_Sadashivamur)\
**Post date:** [August 18, 2015, 10:27am UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531/4 "2015-08-18T10:27:34Z")

</div>

Nik, David,

Thanks for the reply. I was trying to debug the behaviour further. For the same request, response from curl is different from Java client. The scores are also different. The requests and responses for Java client and Curl are as follows. The java client versions 1.3.2 and 1.3.1 has the same response as the curl response. Trying to understand why are they different.

**Java Client Request:**  
{  
"bool" : {  
"should" : [ {  
"match" : {  
"name" : {  
"query" : "name",  
"type" : "boolean"  
}  
}  
}, {  
"match" : {  
"name" : {  
"query" : "INDIVIDUAL",  
"type" : "boolean"  
}  
}  
} ]  
}  
}  
**Java Client Response:**  
{  
"took":38590,  
"timed\_out":false,  
"\_shards":{  
"total":5,  
"successful":5,  
"failed":0  
},  
"hits":{  
"total":3,  
"max\_score":0.11447419,  
"hits":[  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"third",  
"\_score":0.11447419,  
"\_source":{  
"id":"third",  
"name":"IndIVIDUAL",  
"version":0,  
"creationDateInMillis":0  
}  
},  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"first",  
"\_score":0.11447419,  
"\_source":{  
"id":"first",  
"name":"INDIVIDUAL",  
"version":0,  
"creationDateInMillis":0  
}  
},  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"second",  
"\_score":0.11447419,  
"\_source":{  
"id":"second",  
"name":"individual",  
"version":0,  
"creationDateInMillis":0  
}  
}  
]  
}  
}

So I tried to create a same request from curl

**Curl Request**  
curl -XGET [http://localhost:9200/default-index/\_search](http://localhost:9200/default-index/_search) -d '{"query":{"bool":{"should":[{"match":{"name":{"query":"name","type":"boolean"}}},{"match":{"name":{"query":"INDIVIDUAL","type":"boolean"}}}]}}}'

**Curl Response**  
{  
"took":70,  
"timed\_out":false,  
"\_shards":{  
"total":5,  
"successful":5,  
"failed":0  
},  
"hits":{  
"total":3,  
"max\_score":0.09848769,  
"hits":[  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"first",  
"\_score":0.09848769,  
"\_source":{  
"id":"first",  
"name":"INDIVIDUAL",  
"version":0,  
"creationDateInMillis":0  
}  
},  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"second",  
"\_score":0.09848769,  
"\_source":{  
"id":"second",  
"name":"individual",  
"version":0,  
"creationDateInMillis":0  
}  
},  
{  
"\_index":"default-index",  
"\_type":"com-thomsonreuters-grc-platform-util-searching-elasticsearch-DummyObject",  
"\_id":"third",  
"\_score":0.04500804,  
"\_source":{  
"id":"third",  
"name":"IndIVIDUAL",  
"version":0,  
"creationDateInMillis":0  
}  
}  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:55pm UTC](https://discuss.elastic.co/t/java-client-version-upgrade-causing-issues/27531/5 "2017-07-05T23:55:21Z")

</div>


