Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
javanna committed Nov 18, 2024
1 parent ae595e5 commit 92d9135
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -788,18 +788,13 @@ public void testFetchTimeoutWithPartialResults() throws IOException {
w.addDocument(new Document());
IndexReader r = w.getReader();
w.close();
SearchContext searchContext = null;
try {
ContextIndexSearcher contextIndexSearcher = createSearcher(r);
searchContext = createSearchContext(contextIndexSearcher, true);
ContextIndexSearcher contextIndexSearcher = createSearcher(r);
try (SearchContext searchContext = createSearchContext(contextIndexSearcher, true)) {
FetchPhase fetchPhase = createFetchPhase(contextIndexSearcher);
fetchPhase.execute(searchContext, new int[] { 0, 1, 2 }, null);
assertTrue(searchContext.queryResult().searchTimedOut());
assertEquals(1, searchContext.fetchResult().hits().getHits().length);
} finally {
if (searchContext != null) {
searchContext.fetchResult().decRef();
}
r.close();
dir.close();
}
Expand All @@ -813,18 +808,13 @@ public void testFetchTimeoutNoPartialResults() throws IOException {
w.addDocument(new Document());
IndexReader r = w.getReader();
w.close();
SearchContext searchContext = null;
try {
ContextIndexSearcher contextIndexSearcher = createSearcher(r);
searchContext = createSearchContext(contextIndexSearcher, false);
ContextIndexSearcher contextIndexSearcher = createSearcher(r);

try (SearchContext searchContext = createSearchContext(contextIndexSearcher, false)) {
FetchPhase fetchPhase = createFetchPhase(contextIndexSearcher);
SearchContext context = searchContext;
expectThrows(SearchTimeoutException.class, () -> fetchPhase.execute(context, new int[] { 0, 1, 2 }, null));
expectThrows(SearchTimeoutException.class, () -> fetchPhase.execute(searchContext, new int[] { 0, 1, 2 }, null));
assertNull(searchContext.fetchResult().hits());
} finally {
if (searchContext != null) {
searchContext.fetchResult().decRef();
}
r.close();
dir.close();
}
Expand Down Expand Up @@ -940,6 +930,7 @@ public ShardSearchRequest request() {
return request;
}
};
searchContext.addReleasable(searchContext.fetchResult()::decRef);
searchContext.setTask(new SearchShardTask(-1, "type", "action", "description", null, Collections.emptyMap()));
return searchContext;
}
Expand Down

0 comments on commit 92d9135

Please sign in to comment.