# Searching by \_id returns different results when the search is repeated

**URL:** https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577
**Category:** Elasticsearch
**Created:** [June 21, 2021, 7:57pm UTC](https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577 "2021-06-21T19:57:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![BradVido](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradvido/32/741_2.png) [@BradVido](https://discuss.elastic.co/u/BradVido)
#### Post date: [June 21, 2021, 7:57pm UTC](https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577/1 "2021-06-21T19:57:30Z")

</div>

I'm on ES 6.8, with a 3 node cluster, and the status is green.

First of all, I'm aware that I can [Get by ID](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docs-get.html), but for this scenario, I am searching by ID.

My question is.... Is this a bug, or just a quirk of how distributed search works?

This request returns a **single result (as expected):**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c765ee0adc30ee4c3d75238b72d2106147a82352.png)

Repeating the request, returns **no results** :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/5/e5fdacee88a5c14a9d1b812907c229b82f9b63b2.png)

Repeating again will return a single results, and repeating again gives no results. This pattern seems to continue forever.

An interesting note, is that when I do Get by ID for this index/type/id, my first search returns the hit quickly, and the second repeated search will hang (seemingly indefinitely) with no response.

---

<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: [June 22, 2021, 7:50am UTC](https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577/2 "2021-06-22T07:50:35Z")

</div>

Hey,

just to try things out - sounds as if one shard is not reachable and you are running into a timeout and then nothing is returned. By setting the [preference parameter](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-search.html#search-preference) you can hit the same shard with a query and see if only one shard is causing that behaviour, and then take a closer look at the node hosting that shard.

--Alex

---

<div class="post-metadata">

### Author: ![BradVido](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradvido/32/741_2.png) [@BradVido](https://discuss.elastic.co/u/BradVido)
#### Post date: [June 22, 2021, 3:06pm UTC](https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577/3 "2021-06-22T15:06:38Z")

</div>

I think your suspicious are correct @spinscale because after rebooting one of the nodes, all queries are now returning the same data (single doc).

What's concerning is that none of the shards reports skipped/failed...

I can no longer reproduce the issue, but if it happens again, I guess I'll have to dig in more

---

<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 20, 2021, 3:07pm UTC](https://discuss.elastic.co/t/searching-by-id-returns-different-results-when-the-search-is-repeated/276577/4 "2021-07-20T15:07:00Z")

</div>

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