Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9367

Using a queryText which results in zero tokens causes a query to be built as null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 7.2.1
    • None
    • core/search
    • None
    • New

    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:

      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);
          }
      }
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Brier Tim Brier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: