|
25 | 25 | import org.apache.lucene.search.TermInSetQuery; |
26 | 26 | import org.apache.lucene.search.TermQuery; |
27 | 27 | import org.apache.lucene.util.BytesRef; |
| 28 | +import org.apache.lucene.util.BytesRefIterator; |
28 | 29 | import org.apache.lucene.util.NumericUtils; |
29 | 30 | import org.apache.lucene.util.automaton.ByteRunAutomaton; |
30 | 31 | import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; |
31 | 32 | import org.elasticsearch.index.query.DateRangeIncludingNowQuery; |
32 | | -import org.elasticsearch.index.search.NestedHelper; |
33 | 33 | import org.elasticsearch.lucene.queries.BlendedTermQuery; |
34 | 34 |
|
| 35 | +import java.io.IOException; |
| 36 | +import java.io.UncheckedIOException; |
35 | 37 | import java.util.ArrayList; |
36 | 38 | import java.util.Arrays; |
37 | 39 | import java.util.Collections; |
@@ -198,10 +200,16 @@ public void consumeTerms(Query query, Term... termsToConsume) { |
198 | 200 | @Override |
199 | 201 | public void consumeTermsMatching(Query query, String field, Supplier<ByteRunAutomaton> automaton) { |
200 | 202 | if (query instanceof TermInSetQuery q) { |
201 | | - // TODO Lucene 10 upgrade: this is a workaround that only gets one term |
202 | | - Term term = NestedHelper.getTermInSetTerm(q); |
| 203 | + BytesRefIterator bytesRefIterator = q.getBytesRefIterator(); |
| 204 | + BytesRef term; |
203 | 205 | Set<QueryExtraction> qe = new HashSet<>(); |
204 | | - qe.add(new QueryExtraction(term)); |
| 206 | + try { |
| 207 | + while ((term = bytesRefIterator.next()) != null) { |
| 208 | + qe.add(new QueryExtraction(new Term(field, term))); |
| 209 | + } |
| 210 | + } catch (IOException e) { |
| 211 | + throw new UncheckedIOException(e); |
| 212 | + } |
205 | 213 | this.terms.add(new Result(true, qe, 1)); |
206 | 214 | } else { |
207 | 215 | super.consumeTermsMatching(query, field, automaton); |
|
0 commit comments