[ https://issues.apache.org/jira/browse/LUCENE-9524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211490#comment-17211490 ]
Zach Chen commented on LUCENE-9524: ----------------------------------- So after much debugging and tracing, I found that revert-ting the one-line change from https://issues.apache.org/jira/browse/LUCENE-7238 would resolve this NPE issue, but not sure if this is the right approach to be taken here. The underlying issue causing the differences in behavior is that, the *NOT \"dolor lorem\"* in the query above would generate a _SpanNearWeight_ with ScoreMode _COMPLETE_NO_SCORES_ for both cases. However, when _LRUQueryCache_ is available for non MemoryIndex, this weight gets wrapped into _LRUQueryCache$CachingWrapperWeight_, which extends _ConstantScoreWeight_ and doesn't use (the null) simScorer for explanation. So it seems like the use of _LRUQueryCache$CachingWrapperWeight_ can make the underlying potentially variable-score weight to be constant-score weight for explanation. On the other hand, _SpanNearWeight's_ super class _SpanWight_ seems to allow null simScorer field, but its explanation method's call to _LeafSimScorer_ constructor doesn't check for the case of null simScorer. Maybe a check is needed there as well? [~jpountz] Sine from git you worked on both aspects above, I'm wondering what's your take on this? I can work on a patch if needed. > NullPointerException in IndexSearcher.explain() when using > ComplexPhraseQueryParser > ----------------------------------------------------------------------------------- > > Key: LUCENE-9524 > URL: https://issues.apache.org/jira/browse/LUCENE-9524 > Project: Lucene - Core > Issue Type: Bug > Components: core/queryparser, core/search > Affects Versions: 8.6, 8.6.2 > Reporter: Michał Słomkowski > Priority: Major > > 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: > {code} > 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) > {code} > Minimal example code: > {code:java} > 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); > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org