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

NullPointerException in IndexSearcher.explain() when using ComplexPhraseQueryParser

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 8.6, 8.6.2
    • 8.7
    • None

    Description

      I get NPE when I use IndexSearcher.explain(). Checked with Lucene 8.6.0
      and 8.6.2.

      The query: (lorem AND NOT "dolor lorem") OR ipsum
      The text: dolor lorem ipsum

      Stack trace:

      java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203)
      	at org.apache.lucene.search.LeafSimScorer.<init>(LeafSimScorer.java:38)
      	at org.apache.lucene.search.spans.SpanWeight.explain(SpanWeight.java:160)
      	at org.apache.lucene.search.BooleanWeight.explain(BooleanWeight.java:87)
      	at org.apache.lucene.search.BooleanWeight.explain(BooleanWeight.java:87)
      	at org.apache.lucene.search.IndexSearcher.explain(IndexSearcher.java:716)
      	at org.apache.lucene.search.IndexSearcher.explain(IndexSearcher.java:693)
      

      Minimal example code:

      val analyzer = new StandardAnalyzer();
      val query = new ComplexPhraseQueryParser("", analyzer).parse(queryString);
      
      final MemoryIndex memoryIndex = new MemoryIndex(true);
      memoryIndex.addField("", text, analyzer);
      
      final IndexSearcher searcher = memoryIndex.createSearcher();
      final TopDocs topDocs = searcher.search(query, 1);
      
      final ScoreDoc match = topDocs.scoreDocs[0];
      
      searcher.explain(query, match.doc);
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              slomkowski Michał Słomkowski
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h