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

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.2.1
    • Fix Version/s: None
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      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

            • Assignee:
              Unassigned
              Reporter:
              Brier Tim Brier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: