diff --git a/lucene/core/src/java/org/apache/lucene/search/AutomatonQuery.java b/lucene/core/src/java/org/apache/lucene/search/AutomatonQuery.java index 093dd0f53f91..f726a6c60c77 100644 --- a/lucene/core/src/java/org/apache/lucene/search/AutomatonQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/AutomatonQuery.java @@ -91,11 +91,41 @@ public AutomatonQuery(final Term term, Automaton automaton, boolean isBinary) { */ public AutomatonQuery( final Term term, Automaton automaton, boolean isBinary, RewriteMethod rewriteMethod) { + this(term, automaton, false, true, isBinary, rewriteMethod); + } + + /** + * Create a new AutomatonQuery from an {@link Automaton}. + * + * @param term Term containing field and possibly some pattern structure. The term text is + * ignored. + * @param automaton Automaton to run, terms that are accepted are considered a match. + * @param isFinite if true, this automaton is already finite + * @param isBinary if true, this automaton is already binary and will not go through the + * UTF32ToUTF8 conversion + */ + public AutomatonQuery(final Term term, Automaton automaton, boolean isFinite, boolean simplify, boolean isBinary) { + this(term, automaton, isFinite, simplify, isBinary, CONSTANT_SCORE_BLENDED_REWRITE); + } + + /** + * Create a new AutomatonQuery from an {@link Automaton}. + * + * @param term Term containing field and possibly some pattern structure. The term text is + * ignored. + * @param automaton Automaton to run, terms that are accepted are considered a match. + * @param isFinite if true, this automaton is already finite + * @param isBinary if true, this automaton is already binary and will not go through the + * UTF32ToUTF8 conversion + * @param rewriteMethod the rewriteMethod to use to build the final query from the automaton + */ + public AutomatonQuery( + final Term term, Automaton automaton, boolean isFinite, boolean simplify, boolean isBinary, RewriteMethod rewriteMethod) { super(term.field(), rewriteMethod); this.term = term; this.automaton = automaton; this.automatonIsBinary = isBinary; - this.compiled = new CompiledAutomaton(automaton, false, true, isBinary); + this.compiled = new CompiledAutomaton(automaton, isFinite, simplify, isBinary); this.ramBytesUsed = BASE_RAM_BYTES + term.ramBytesUsed() + automaton.ramBytesUsed() + compiled.ramBytesUsed(); diff --git a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java index 13a10b70abb6..ac1497b51849 100644 --- a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java @@ -69,7 +69,7 @@ public class TermInSetQuery extends AutomatonQuery { private final int termCount; public TermInSetQuery(String field, Collection terms) { - super(new Term(field), toAutomaton(terms), true); + super(new Term(field), toAutomaton(terms), true, false, true); this.field = field; this.termCount = terms.size(); } @@ -80,7 +80,7 @@ public TermInSetQuery(String field, BytesRef... terms) { /** Creates a new {@link TermInSetQuery} from the given collection of terms. */ public TermInSetQuery(RewriteMethod rewriteMethod, String field, Collection terms) { - super(new Term(field), toAutomaton(terms), true, rewriteMethod); + super(new Term(field), toAutomaton(terms), true, false, true, rewriteMethod); this.field = field; this.termCount = terms.size(); }