Check if accessible
This commit is contained in:
parent
956f33fb6c
commit
cc9306fbde
@ -73,9 +73,13 @@ public class CountMultiSearcher implements MultiSearcher {
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, mergedFluxes, () -> {
|
||||
for (LuceneSearchResult luceneSearchResult : resultsToDrop) {
|
||||
if (luceneSearchResult.isAccessible()) {
|
||||
luceneSearchResult.close();
|
||||
}
|
||||
}
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, false));
|
||||
|
@ -54,8 +54,16 @@ public class PagedLocalSearcher implements LocalSearcher {
|
||||
.transform(firstPageTopDocsMono -> this.computeFirstPageResults(firstPageTopDocsMono, indexSearchers.shards(),
|
||||
keyFieldName, queryParams2))
|
||||
// Compute other results
|
||||
.transform(firstResult -> this.computeOtherResults(firstResult, indexSearchers.shards(), queryParams2,
|
||||
keyFieldName, indexSearchers::close))
|
||||
.transform(firstResult -> this.computeOtherResults(firstResult,
|
||||
indexSearchers.shards(),
|
||||
queryParams2,
|
||||
keyFieldName,
|
||||
() -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
}
|
||||
))
|
||||
// Ensure that one LuceneSearchResult is always returned
|
||||
.single()
|
||||
);
|
||||
|
@ -62,8 +62,16 @@ public class ScoredPagedMultiSearcher implements MultiSearcher {
|
||||
.transform(firstPageTopDocsMono -> this.computeFirstPageResults(firstPageTopDocsMono, indexSearchers,
|
||||
keyFieldName, queryParams2))
|
||||
// Compute other results
|
||||
.map(firstResult -> this.computeOtherResults(firstResult, indexSearchers.shards(),
|
||||
queryParams2, keyFieldName, indexSearchers::close))
|
||||
.map(firstResult -> this.computeOtherResults(firstResult,
|
||||
indexSearchers.shards(),
|
||||
queryParams2,
|
||||
keyFieldName,
|
||||
() -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
}
|
||||
))
|
||||
// Ensure that one LuceneSearchResult is always returned
|
||||
.single(),
|
||||
false);
|
||||
|
@ -127,7 +127,9 @@ public class SortedByScoreFullMultiSearcher implements MultiSearcher {
|
||||
.take(queryParams.limitLong(), true);
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, hitsFlux, () -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
try {
|
||||
data.close();
|
||||
} catch (Exception e) {
|
||||
|
@ -121,7 +121,9 @@ public class SortedScoredFullMultiSearcher implements MultiSearcher {
|
||||
.take(queryParams.limitLong(), true);
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, hitsFlux, () -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
data.close();
|
||||
});
|
||||
});
|
||||
|
@ -143,7 +143,11 @@ public class StandardSearcher implements MultiSearcher {
|
||||
.skip(queryParams.offsetLong())
|
||||
.take(queryParams.limitLong(), true);
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, hitsFlux, indexSearchers::close);
|
||||
return new LuceneSearchResult(totalHitsCount, hitsFlux, () -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,11 @@ public class UnsortedStreamingMultiSearcher implements MultiSearcher {
|
||||
.skip(queryParams2.offsetLong())
|
||||
.take(queryParams2.limitLong(), true);
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, mergedFluxes, indexSearchers::close);
|
||||
return new LuceneSearchResult(totalHitsCount, mergedFluxes, () -> {
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
@ -74,9 +74,13 @@ public class UnsortedUnscoredSimpleMultiSearcher implements MultiSearcher {
|
||||
|
||||
return new LuceneSearchResult(totalHitsCount, mergedFluxes, () -> {
|
||||
for (LuceneSearchResult luceneSearchResult : resultsToDrop) {
|
||||
if (luceneSearchResult.isAccessible()) {
|
||||
luceneSearchResult.close();
|
||||
}
|
||||
}
|
||||
if (indexSearchers.isAccessible()) {
|
||||
indexSearchers.close();
|
||||
}
|
||||
});
|
||||
})
|
||||
.doFirst(() -> {
|
||||
|
Loading…
Reference in New Issue
Block a user