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

Flexible StandardQueryParser behaves differently than ClassicQueryParser

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.5
    • Fix Version/s: 4.6.1, 4.7, 6.0
    • Component/s: core/queryparser
    • Labels:
      None

      Description

      AnalyzerQueryNodeProcessor creates a BooleanQueryNode instead of a MultiPhraseQueryNode for some circumstances.

      Classic query parser output: +content:a +content:320 (correct)

      QueryParser classicQueryParser;
      classicQueryParser = new QueryParser(Version.LUCENE_45, "content", anaylzer);
      classicQueryParser.setDefaultOperator(Operator.AND);
      classicQueryParser.parse("a320"));
      

      Flexible query parser output: content:a content:320 (wrong)

      StandardQueryParser flexibleQueryParser;
      flexibleQueryParser = new StandardQueryParser(anaylzer);
      flexibleQueryParser.setDefaultOperator(Operator.AND);
      flexibleQueryParser.parse("a320", "content"));
      

      The used analyzer:

      Analyzer anaylzer = return new Analyzer() {
        protected TokenStreamComponents createComponents(String field, Reader in) {
        Tokenizer   src = new WhitespaceTokenizer(Version.LUCENE_45, in);
        TokenStream tok = new WordDelimiterFilter(src,
           WordDelimiterFilter.SPLIT_ON_NUMERICS |
           WordDelimiterFilter.GENERATE_WORD_PARTS |
           WordDelimiterFilter.GENERATE_NUMBER_PARTS,
           CharArraySet.EMPTY_SET); 
        return new TokenStreamComponents(src, tok);
      };
      

        Attachments

          Activity

            People

            • Assignee:
              adriano_crestani Adriano Crestani
              Reporter:
              Krishna Keldec Krishna Keldec
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: