# Same query return different result

**URL:** <https://discuss.elastic.co/t/same-query-return-different-result/98206>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 10:10am UTC](https://discuss.elastic.co/t/same-query-return-different-result/98206 "2017-08-24T10:10:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ydj](https://avatars.discourse-cdn.com/v4/letter/y/a88e57/32.png) [@ydj](https://discuss.elastic.co/u/ydj)\
**Post date:** [August 24, 2017, 10:10am UTC](https://discuss.elastic.co/t/same-query-return-different-result/98206/1 "2017-08-24T10:10:14Z")

</div>

I have 3 servers，i find that same query has different result  
ip1：9200 and ip2：9200 return right result，but ip3：9200 return wrong result.  
ip1 and ip2 result：  
{  
"took": 3,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 7,  
"max\_score": null,  
"hits": [  
{  
......

ip3 result：  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 3,  
"failed": 0  
},  
"hits": {  
"total": 3,  
"max\_score": null,  
"hits": [  
{  
......

client initmode ：  
Settings settings = Settings.builder()  
.put("[cluster.name](http://cluster.name)", config.getEsClusterName())  
.put("client.transport.sniff", true)  
.put("client.transport.ping\_timeout", "60s").build();  
try {  
client = new PreBuiltTransportClient(settings);  
String[] ips = config.getEsClusterIp().split(",");  
for (String ip : ips) {  
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.valueOf(config.getEsClusterPort())));  
}  
query mode：  
SearchRequestBuilder requestBuilder = client.prepareSearch(config.getIndex()).setTypes(config.getType())  
.setPreference("\_primary")  
.setQuery(boolQueryBuilder)  
.setFrom(Integer.valueOf(startIndex))  
.setSize(Integer.valueOf(pageSize))  
.addSort(sortBuilder);  
This problem has been bothering me for a long time. Please help me，thanks！

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 8:14am UTC](https://discuss.elastic.co/t/same-query-return-different-result/98206/2 "2017-08-25T08:14:28Z")

</div>

Hey,

take a closer look ay your responses. First query

```auto
"_shards": {
  “total”: 5,
  “successful”: 5,
  “failed”: 0
}

```

second query

```auto
"_shards": {
  “total”: 5,
  “successful”: 3,
  “failed”: 0
}

```

The second query did span the same number of shards than the first one. Looks as if some shards were not reachable during query execution. Maybe you cluster has stability issues.

--Alex

---

<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:** [September 22, 2017, 8:14am UTC](https://discuss.elastic.co/t/same-query-return-different-result/98206/3 "2017-09-22T08:14:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
