# Search scroll returning no hits (possible bug in 6.2?)

**URL:** https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578
**Category:** Elasticsearch
**Created:** [June 12, 2018, 5:53pm UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578 "2018-06-12T17:53:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [June 12, 2018, 5:53pm UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578/1 "2018-06-12T17:53:57Z")

</div>

After an upgrade made to 6.2 our scrolling does no longer work. We are currently using a java client for it that follows the docs for first and subsequent requests ([https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html)). To avoid any noise with the java client the requests are also done in the Kibana console and results confirm the issue. More details to follow

The example on the rest API is as follow:

First search request:

```
POST /cipher/_search?scroll=1m
{"size":500,"query":{"bool":{"must":[{"match_all":{"boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"post_filter":{"has_child":{"query":{"bool":{"must":[{"bool":{"should":[{"term":{"processId":{"value":"511e1-v053-947a5-966d30281c4c16ad10c084533edd4a_511e1-v053-947a5-966d30281c4c16ad10c084533edd4a","boost":1.0}}}],"adjust_pure_negative":true,"boost":1.0}},{"bool":{"should":[{"match":{"clusterId":{"query":0,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":1,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":2,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":3,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":4,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":5,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":6,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":7,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":8,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":9,"operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}}],"adjust_pure_negative":true,"boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"type":"process","score_mode":"none","min_children":0,"max_children":2147483647,"ignore_unmapped":false,"boost":1.0,"inner_hits":{"ignore_unmapped":false,"from":0,"size":3,"version":false,"explain":false,"track_scores":false}}},"explain":false,"_source":{"includes":["grantedTerritories","priorityDate","patentNumbers","accession","title","status"],"excludes":[]}}

```

It returns 500 results:

```
    {
      "_scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAADX9Fkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA1_hZHNUhLT2hPelE5ZVBJY3FCaGd3MlZnAAAAAAAANf8WRzVIS09oT3pROWVQSWNxQmhndzJWZwAAAAAAADYAFkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA2ARZHNUhLT2hPelE5ZVBJY3FCaGd3MlZn",
      "took": 396,
      "timed_out": false,
      "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": 1075,
        "max_score": 1,
        "hits": [ {
    "_index": "cipher",
    "_type": "_doc",
    "_id": "5254018",
    "_score": 1,
    "_source": {
      "grantedTerritories": [
        "DE",
        "CH",
        "GB",
        "FR"
      ],
     ...]
      }
    }

```

Then it follows the search scroll:

```
POST /_search/scroll 
{
    "scroll" : "1m", 
    "scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAADX9Fkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA1_hZHNUhLT2hPelE5ZVBJY3FCaGd3MlZnAAAAAAAANf8WRzVIS09oT3pROWVQSWNxQmhndzJWZwAAAAAAADYAFkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA2ARZHNUhLT2hPelE5ZVBJY3FCaGd3MlZn"   
}

```

But it returns the following (please note the empty array of hits):

```
{
  "_scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAADX9Fkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA1_hZHNUhLT2hPelE5ZVBJY3FCaGd3MlZnAAAAAAAANf8WRzVIS09oT3pROWVQSWNxQmhndzJWZwAAAAAAADYAFkc1SEtPaE96UTllUEljcUJoZ3cyVmcAAAAAAAA2ARZHNUhLT2hPelE5ZVBJY3FCaGd3MlZn",
  "took": 1,
  "timed_out": false,
  "terminated_early": true,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1110,
    "max_score": 1,
    "hits": []
  }
}

```

What am I missing to get the next batch?

---

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [June 13, 2018, 8:40am UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578/2 "2018-06-13T08:40:49Z")

</div>

Also finding some issues on the ES host (self hosted, simply one node)

```
[2018-06-13T08:27:32,030][DEBUG][o.e.a.s.TransportSearchScrollAction] [masterdata-node-1] [14332] Failed to execute query phase
org.elasticsearch.transport.RemoteTransportException: [masterdata-node-1][192.168.3.187:9300][indices:data/read/search[phase/query/scroll]]
Caused by: org.elasticsearch.search.SearchContextMissingException: No search context found for id [14332]
	at org.elasticsearch.search.SearchService.findContext(SearchService.java:520) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:391) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:410) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:407) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:656) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:672) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.2.3.jar:6.2.3]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
[2018-06-13T08:27:32,030][DEBUG][o.e.a.s.TransportSearchScrollAction] [masterdata-node-1] [14333] Failed to execute query phase
org.elasticsearch.transport.RemoteTransportException: [masterdata-node-1][192.168.3.187:9300][indices:data/read/search[phase/query/scroll]]
Caused by: org.elasticsearch.search.SearchContextMissingException: No search context found for id [14333]
	at org.elasticsearch.search.SearchService.findContext(SearchService.java:520) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:391) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:410) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:407) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66) ~[elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:656) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:672) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.2.3.jar:6.2.3]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.2.3.jar:6.2.3]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]

```

Any help/hint would be really appreciated

---

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [June 13, 2018, 2:46pm UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578/3 "2018-06-13T14:46:18Z")

</div>

This problem seems to be related with the "post\_filter" object on the initial request, that in turn comes from doing a parent\_child request, namely:

"post\_filter":{"has\_child":{"query":{"bool":{"must":[{"bool":{"should":[{"term":{"processId":{"value":"511e1-v053-947a5-966d30281c4c16ad10c084533edd4a\_511e1-v053-947a5-966d30281c4c16ad10c084533edd4a","boost":1.0}}}],"adjust\_pure\_negative":true,"boost":1.0}},{"bool":{"should":[{"match":{"clusterId":{"query":0,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":1,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":2,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":3,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":4,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":5,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":6,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":7,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":8,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}},{"match":{"clusterId":{"query":9,"operator":"OR","prefix\_length":0,"max\_expansions":50,"fuzzy\_transpositions":true,"lenient":false,"zero\_terms\_query":"NONE","auto\_generate\_synonyms\_phrase\_query":true,"boost":1.0}}}],"adjust\_pure\_negative":true,"boost":1.0}}],"adjust\_pure\_negative":true,"boost":1.0}},"type":"process","score\_mode":"none","min\_children":0,"max\_children":2147483647,"ignore\_unmapped":false,"boost":1.0,"inner\_hits":{"ignore\_unmapped":false,"from":0,"size":3,"version":false,"explain":false,"track\_scores":false}}}

Still investigating/looking for a solution

---

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [June 13, 2018, 3:31pm UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578/4 "2018-06-13T15:31:26Z")

</div>

It seems related with this issue: [No hit using scan/scroll with has\_parent filter](https://discuss.elastic.co/t/no-hit-using-scan-scroll-with-has-parent-filter/15143/4)

However I'm using 6.2 API, shouldn't that be fixed?  
...  
SearchRequest searchRequest = new SearchRequest(CIPHER\_INDEX)  
.source((new SearchSourceBuilder()  
.query(QueryBuilders.boolQuery().must(getMatchQuery(searchFor)))  
.postFilter(JoinQueryBuilders.hasChildQuery(ElasticConstants.CHILD\_JOIN\_REL,  
filterByProcessAndCluster(reportMetadata.target().process(), processes, allClusters),  
ScoreMode.None)  
.innerHit(new InnerHitBuilder()))  
.explain(false)))  
.types(CIPHER\_TYPE)  
.searchType(SearchType.QUERY\_THEN\_FETCH);  
...  
elasticClient.search(searchRequest);  
...  
elasticClient.searchScroll(new SearchScrollRequest(result.getScrollId()))  
...

---

<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 11, 2018, 3:42pm UTC](https://discuss.elastic.co/t/search-scroll-returning-no-hits-possible-bug-in-6-2/135578/5 "2018-07-11T15:42:57Z")

</div>

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