Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IntervalBuilder#analyzeText to never return null #42750

Merged
merged 2 commits into from
May 31, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected IntervalsSource analyzeText(CachingTokenFilter stream, int maxGaps, bo
// formulate a single term, boolean, or phrase.

if (numTokens == 0) {
return null;
return NO_INTERVALS;
} else if (numTokens == 1) {
// single term
return analyzeTerm(stream);
Expand Down Expand Up @@ -231,7 +231,7 @@ protected List<IntervalsSource> analyzeGraph(TokenStream source) throws IOExcept
return clauses;
}

private static final IntervalsSource NO_INTERVALS = new IntervalsSource() {
static final IntervalsSource NO_INTERVALS = new IntervalsSource() {

@Override
public IntervalIterator intervals(String field, LeafReaderContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public void testPhraseWithStopword() throws IOException {

}

public void testEmptyTokenStream() throws IOException {
CannedTokenStream ts = new CannedTokenStream();
IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), 0, true);
assertSame(IntervalBuilder.NO_INTERVALS, source);
}

public void testSimpleSynonyms() throws IOException {

CannedTokenStream ts = new CannedTokenStream(
Expand Down