LUCENE-7576: fix other codecs to detect when special case automaton is passed to Terms.intersect

This commit is contained in:
Mike McCandless 2016-12-02 17:42:27 -05:00
parent 58476b1675
commit 8cbcbc9d95
3 changed files with 9 additions and 0 deletions

View File

@ -659,6 +659,9 @@ public final class DirectPostingsFormat extends PostingsFormat {
@Override
public TermsEnum intersect(CompiledAutomaton compiled, final BytesRef startTerm) {
if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
}
return new DirectIntersectTermsEnum(compiled, startTerm);
}

View File

@ -270,6 +270,9 @@ public class FSTOrdTermsReader extends FieldsProducer {
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
}
return new IntersectTermsEnum(compiled, startTerm);
}

View File

@ -250,6 +250,9 @@ public class FSTTermsReader extends FieldsProducer {
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
}
return new IntersectTermsEnum(compiled, startTerm);
}