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