[ https://issues.apache.org/jira/browse/LUCENE-9367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17101786#comment-17101786 ]
Alan Woodward commented on LUCENE-9367: --------------------------------------- `null` does seem like the wrong thing to do here - maybe we should be returning a MatchNoDocsQuery instead? > Using a queryText which results in zero tokens causes a query to be built as > null > --------------------------------------------------------------------------------- > > Key: LUCENE-9367 > URL: https://issues.apache.org/jira/browse/LUCENE-9367 > Project: Lucene - Core > Issue Type: Bug > Components: core/search > Affects Versions: 7.2.1 > Reporter: Tim Brier > Priority: Major > > If a queryText produces zero tokens after being processed by an Analyzer, > when you try to build a Query with it the result is null. > > The following code reproduces this bug: > {code:java} > public class LuceneBug { > public Query buildQuery() throws IOException { > Analyzer analyzer = CustomAnalyzer.builder() > .withTokenizer(StandardTokenizerFactory.class) > .addTokenFilter(StopFilterFactory.class) > .build(); > QueryBuilder queryBuilder = new QueryBuilder(analyzer); > String onlyStopWords = "the and it"; > return queryBuilder.createPhraseQuery("AnyField", onlyStopWords); > } > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org