jpountz commented on a change in pull request #1978: URL: https://github.com/apache/lucene-solr/pull/1978#discussion_r505009820
########## 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 { Review comment: I don't think this is specific to MemoryIndex, so can you move this test to TestSpansExplanations? ########## 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: can you assert on the explanation string? ---------------------------------------------------------------- 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