-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrolling with has_child filter returns no hits on 2nd request #4703
Comments
I've written this up as a an integration test and used git bisect to try and track down where this broke between 0.90.5 and 0.90.6. It looks like this commit 9950e44 seems to be the culprit. This is the test method I'm using. @Test
public void simpleScrolledHasChildFilteredQuery() throws Exception {
client().admin().indices().prepareCreate("test")
.setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0))
.execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
client().admin()
.indices()
.preparePutMapping("test")
.setType("child")
.setSource(
jsonBuilder().startObject().startObject("child").startObject("_parent").field("type", "parent").endObject()
.endObject().endObject()).execute().actionGet();
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "parent", "p" + i).setSource("{}").execute().actionGet();
client().prepareIndex("test", "child", "c" + i).setSource("{}").setParent("p" + i).execute().actionGet();
}
client().admin().indices().prepareRefresh().execute().actionGet();
final SearchResponse scrollResponse = client().prepareSearch("test")
.setScroll(TimeValue.timeValueSeconds(30))
.setSize(1)
.addField("_id")
.setTypes("parent")
.setQuery(filteredQuery(matchAllQuery(), FilterBuilders.hasChildFilter("child", matchAllQuery())))
.execute()
.actionGet();
final SearchResponse firstScroll = client().prepareSearchScroll(scrollResponse.getScrollId()).setScroll(TimeValue.timeValueSeconds(30)).execute().actionGet();
final SearchResponse secondScroll = client().prepareSearchScroll(firstScroll.getScrollId()).setScroll(TimeValue.timeValueSeconds(30)).execute().actionGet();
client().prepareClearScroll().addScrollId(secondScroll.getScrollId()).execute().actionGet();
assertThat(scrollResponse.getFailedShards(), equalTo(0));
assertThat(scrollResponse.getHits().totalHits(), equalTo(10l));
assertThat(firstScroll.getFailedShards(), equalTo(0));
assertThat(firstScroll.getHits().getHits().length, equalTo(1));
assertThat(secondScroll.getFailedShards(), equalTo(0));
assertThat(secondScroll.getHits().getHits().length, equalTo(1));
} |
Nice catch! I further looked into this issue and this error only seems to occur with the has_child or has_parent filter, but not with the has_child / has_parent query. |
Thanks for fixing it. |
…nts instead of keeping the weight around and build a DocIdSet when a segment is being processed. This fixes issues where the has_child / has_parent filter produce no results or errors on subsequent scan requests. Also made CustomQueryWrappingFilter implement Releasable in order to cleanup the pre-computed DocIdSets. Closes elastic#4703
…nts instead of keeping the weight around and build a DocIdSet when a s Also made CustomQueryWrappingFilter implement Releasable in order to cleanup the pre-computed DocIdSets. Closes #4703
…nts instead of keeping the weight around and build a DocIdSet when a s Also made CustomQueryWrappingFilter implement Releasable in order to cleanup the pre-computed DocIdSets. Closes elastic#4703
This issue seems to still happening in 6.2? Different API but not results are fetched when combining post filter with scrolling |
When using scroll with a has_child filter, the initial request returns the correct total number of hits, but subsequent requests return no hits.
It looks like this problem was introduced in 0.90.6, and still occurs in 0.90.10. 0.90.5 works as expected.
The number of documents seems to play a part - in my initial test cases with only 2 parent documents, I couldn't reproduce the issue. However, creating 100 parents does reliably reproduce it. In my testing, 8 parent documents worked fine, but 9 did not.
It sounds very similar to the issue mentioned here: http://elasticsearch-users.115913.n3.nabble.com/No-hit-using-scan-scroll-with-has-parent-filter-td4047236.html
Here's a test script (requires jq(1) to grab the scroll ID from the first JSON result):
The failing output on 0.90.10:
And the expected output as per 0.90.5:
The text was updated successfully, but these errors were encountered: