You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Tim Brier (Jira)" <ji...@apache.org> on 2020/05/07 14:21:00 UTC

[jira] [Updated] (LUCENE-9367) Using a queryText which results in zero tokens causes a query to be built as null

     [ https://issues.apache.org/jira/browse/LUCENE-9367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Brier updated LUCENE-9367:
------------------------------
    Description: 
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}
 

  was:
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}
 


> 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-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org