Index: lucene/src/java/org/apache/lucene/search/AutomatonTermsEnum.java =================================================================== --- lucene/src/java/org/apache/lucene/search/AutomatonTermsEnum.java (revision 1076635) +++ lucene/src/java/org/apache/lucene/search/AutomatonTermsEnum.java (working copy) @@ -121,10 +121,17 @@ } // seek to the next possible string; - if (nextString()) { - return seekBytesRef; // reposition - } else { - return null; // no more possible strings can match + for (;;) { + if (nextString()) { + System.out.println("candidate: " + seekBytesRef); + if (nextPossiblePrefix(seekBytesRef) == SeekStatus.FOUND) { + System.out.println("found!"); + return seekBytesRef; // reposition + } + System.out.println("not found, goto: " + seekBytesRef); + } else { + return null; // no more possible strings can match + } } } Index: lucene/src/java/org/apache/lucene/search/FilteredTermsEnum.java =================================================================== --- lucene/src/java/org/apache/lucene/search/FilteredTermsEnum.java (revision 1076635) +++ lucene/src/java/org/apache/lucene/search/FilteredTermsEnum.java (working copy) @@ -25,6 +25,7 @@ import org.apache.lucene.index.TermsEnum; import org.apache.lucene.index.DocsEnum; import org.apache.lucene.index.DocsAndPositionsEnum; +import org.apache.lucene.index.TermsEnum.SeekStatus; import org.apache.lucene.util.AttributeSource; import org.apache.lucene.util.Bits; @@ -135,7 +136,7 @@ * @throws UnsupportedOperationException */ @Override - public SeekStatus seek(BytesRef term, boolean useCache) throws IOException { + public SeekStatus seek(BytesRef term, boolean useCache, boolean exactOnly) throws IOException { throw new UnsupportedOperationException(getClass().getName()+" does not support seeking"); } @@ -169,7 +170,13 @@ public void seek(BytesRef term, TermState state) throws IOException { throw new UnsupportedOperationException(getClass().getName()+" does not support seeking"); } - + + /** returns the underlying term enum's next possible prefix */ + @Override + public SeekStatus nextPossiblePrefix(BytesRef prefix) throws IOException { + return tenum.nextPossiblePrefix(prefix); + } + /** * Returns the filtered enums term state */ @@ -189,7 +196,7 @@ final BytesRef t = nextSeekTerm(actualTerm); // Make sure we always seek forward: assert actualTerm == null || t == null || getComparator().compare(t, actualTerm) > 0: "curTerm=" + actualTerm + " seekTerm=" + t; - if (t == null || tenum.seek(t, false) == SeekStatus.END) { + if (t == null || tenum.seek(t, false, false) == SeekStatus.END) { // no more terms to seek to or enum exhausted return null; }