Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix ShardSearchFailure in transport-grpc ([#20641](https://github.com/opensearch-project/OpenSearch/pull/20641))
- Fix TLS cert hot-reload for Arrow Flight transport ([#20732](https://github.com/opensearch-project/OpenSearch/pull/20732))
- Fix misleading heap usage cancellation message in SearchBackpressureService ([#20779](https://github.com/opensearch-project/OpenSearch/pull/20779))
- - Delegate getMin/getMax methods for ExitableTerms ([#20775](https://github.com/opensearch-project/OpenSearch/pull/20775))
- Delegate getMin/getMax methods for ExitableTerms ([#20775](https://github.com/opensearch-project/OpenSearch/pull/20775))
- Fix terms lookup subquery fetch limit reading from non-existent index setting instead of cluster `max_clause_count` ([#20823](https://github.com/opensearch-project/OpenSearch/pull/20823))
- Fix array_index_out_of_bounds_exception with wildcard and aggregations ([#20842](https://github.com/opensearch-project/OpenSearch/pull/20842))

### Dependencies
- Bump shadow-gradle-plugin from 8.3.9 to 9.3.1 ([#20569](https://github.com/opensearch-project/OpenSearch/pull/20569))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ static class WildcardMatchingQuery extends Query {
private final Query firstPhaseQuery;
private final Predicate<String> secondPhaseMatcher;
private final String patternString; // For toString
private final ValueFetcher valueFetcher;
private final Supplier<ValueFetcher> valueFetcherSupplier;
private final SearchLookup searchLookup;

WildcardMatchingQuery(String fieldName, Query firstPhaseQuery, String patternString) {
Expand All @@ -764,10 +764,10 @@ public WildcardMatchingQuery(
this.patternString = Objects.requireNonNull(patternString);
if (context != null) {
this.searchLookup = context.lookup();
this.valueFetcher = fieldType.valueFetcher(context, context.lookup(), null);
this.valueFetcherSupplier = () -> fieldType.valueFetcher(context, context.lookup(), null);
} else {
this.searchLookup = null;
this.valueFetcher = null;
this.valueFetcherSupplier = null;
}
}

Expand All @@ -776,14 +776,14 @@ private WildcardMatchingQuery(
Query firstPhaseQuery,
Predicate<String> secondPhaseMatcher,
String patternString,
ValueFetcher valueFetcher,
Supplier<ValueFetcher> valueFetcherSupplier,
SearchLookup searchLookup
) {
this.fieldName = fieldName;
this.firstPhaseQuery = firstPhaseQuery;
this.secondPhaseMatcher = secondPhaseMatcher;
this.patternString = patternString;
this.valueFetcher = valueFetcher;
this.valueFetcherSupplier = valueFetcherSupplier;
this.searchLookup = searchLookup;
}

Expand Down Expand Up @@ -821,7 +821,7 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
rewriteFirstPhase,
secondPhaseMatcher,
patternString,
valueFetcher,
valueFetcherSupplier,
searchLookup
);
}
Expand All @@ -844,6 +844,9 @@ public Scorer get(long leadCost) throws IOException {
Scorer approximateScorer = firstPhaseSupplier.get(leadCost);
DocIdSetIterator approximation = approximateScorer.iterator();
LeafSearchLookup leafSearchLookup = searchLookup.getLeafSearchLookup(context);
// Create a new ValueFetcher per thread.
// ValueFetcher.setNextReader is not thread safe.
final ValueFetcher valueFetcher = valueFetcherSupplier.get();
valueFetcher.setNextReader(context);

TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(approximation) {
Expand Down
Loading