zacharymorn commented on a change in pull request #1978: URL: https://github.com/apache/lucene-solr/pull/1978#discussion_r505127766
########## File path: lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java ########## @@ -618,4 +622,21 @@ public void testToStringDebug() { "fields=2, terms=2, positions=3", mi.toStringDebug()); } + public void testExplain() throws ParseException, IOException { + String queryString = "(lorem AND NOT \"dolor lorem\") OR ipsum"; + String text = "dolor lorem ipsum"; + + Analyzer analyzer = new MockAnalyzer(random()); + Query query = new ComplexPhraseQueryParser("content", analyzer).parse(queryString); + + MemoryIndex memoryIndex = new MemoryIndex(true); + memoryIndex.addField("content", text, analyzer); + + IndexSearcher searcher = memoryIndex.createSearcher(); + + TopDocs topDocs = searcher.search(query, 1); + ScoreDoc match = topDocs.scoreDocs[0]; + searcher.explain(query, match.doc); Review comment: I've tried this and it seems to be a bit more complicated to do. The problem here is that under the current test setup, the new explanation string code will only be exercised when there's a match between the (none-scoring) prohibited clause and the text. So the matched topDoc that exercised that code path will actually not include that particular explanation as it must have been matching alternative clause instead. Therefore, I'm considering two alternatives here. One would be to test `SpanWeight#explain` directly with null `SimScorer`; the other would be to setup another test to match span query without scoring, but I tried query with Occur.FILTER and MUST and see there's still a 1.0 boost associated and valid `SimScorer`. So I'm not sure if the latter approach is something actually achievable / meaningful to implement? <img width="944" alt="Screen Shot 2020-10-14 at 7 26 18 PM" src="https://user-images.githubusercontent.com/2986273/96069558-540acb00-0e53-11eb-94b3-6a803ba5cb12.png"> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org