/** Returns an Explanation that describes how <code>doc</code> scored against * <code>query</code>. * * <p>This is intended to be used in developing Similarity implementations, * and, for good performance, should not be displayed with every hit. * Computing an explanation is as expensive as executing the query over the * entire index. */ public Explanation explain(Query query, int doc) throws IOException { query = rewrite(query); return explain(createWeight(query, true, 1), doc); }
@Override public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException { Explanation secondPassExplanation = searcher.explain(query, docID); Float secondPassScore = secondPassExplanation.isMatch() ? secondPassExplanation.getValue() : null; float score; if (secondPassScore == null) { score = combine(firstPassExplanation.getValue(), false, 0.0f); } else { score = combine(firstPassExplanation.getValue(), true, secondPassScore.floatValue()); } Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation); Explanation second; if (secondPassScore == null) { second = Explanation.noMatch("no second pass score"); } else { second = Explanation.match(secondPassScore, "second pass score", secondPassExplanation); } return Explanation.match(score, "combined first and second pass score using " + getClass(), first, second); }
@Override public Explanation explain(final Weight weight, final int doc) throws IOException { return searcher.explain(weight, doc); }
@Override public Explanation explain(final Query query, final int doc) throws IOException { return searcher.explain(query, doc); }
final Explanation explain(final int docId) throws IOException { return queryContext.indexSearcher.explain(query, docId); } }
public Explanation explain(int docId) { try { return indexSearcher.explain( luceneQuery, docId ); } catch (IOException e) { throw log.ioExceptionOnExplain( e ); } } }
/** Returns an Explanation that describes how <code>doc</code> scored against * <code>query</code>. * * <p>This is intended to be used in developing Similarity implementations, * and, for good performance, should not be displayed with every hit. * Computing an explanation is as expensive as executing the query over the * entire index. */ public Explanation explain(Query query, int doc) throws IOException { return explain(createNormalizedWeight(query, true), doc); }
public void perform(IndexSearcher searcher) throws IOException { Explanation e = searcher.explain(myquery, docid); sb.append(e.toHtml()); } });
/** Returns an Explanation that describes how <code>doc</code> scored against * <code>query</code>. * * <p>This is intended to be used in developing Similarity implementations, * and, for good performance, should not be displayed with every hit. * Computing an explanation is as expensive as executing the query over the * entire index. */ public Explanation explain(Query query, int doc) throws IOException { return explain(createNormalizedWeight(query, true), doc); }
Explanation rescoreExplain = searcher.explain(rescore.query(), topLevelDocId);
/** Returns an Explanation that describes how <code>doc</code> scored against * <code>query</code>. * * <p>This is intended to be used in developing Similarity implementations, * and, for good performance, should not be displayed with every hit. * Computing an explanation is as expensive as executing the query over the * entire index. */ public Explanation explain(Query query, int doc) throws IOException { query = rewrite(query); return explain(createWeight(query, true, 1), doc); }
@Override public void doMatchQuery(String queryId, Query matchQuery, Map<String, String> metadata) throws IOException { int maxDocs = docs.getIndexReader().maxDoc(); for (int i = 0; i < maxDocs; i++) { Explanation explanation = docs.getSearcher().explain(matchQuery, i); if (explanation.isMatch()) addMatch(new ExplainingMatch(queryId, docs.resolveDocId(i), explanation)); } }
@Test public void testExplain() throws IOException { this.addDocuments( doc(token("three", node(1)), token("hundred", node(1)), token("thirty", node(1)), token("three", node(1))) ); TermSpanQuery term1 = new TermSpanQuery(new Term(DEFAULT_TEST_FIELD, "three")); TermSpanQuery term2 = new TermSpanQuery(new Term(DEFAULT_TEST_FIELD, "thirty")); NearSpanQuery near1 = new NearSpanQuery(new TermSpanQuery[] {term1, term2}, 0, false); Query query = new LuceneProxyNodeQuery(near1); Explanation explanation = searcher.explain(query, 0); assertNotNull(explanation); }
@Test public void testExplain() throws Exception { this.setAnalyzer(AnalyzerType.JSON); this.addDocument("{\"aaa\" : \"bbb\"}"); Query query = ntq("aaa").getLuceneProxyQuery(); final Explanation exp = searcher.explain(query, 0); assertTrue(exp.getValue() != 0); }
@Test public void testExplain() throws Exception { this.setAnalyzer(AnalyzerType.JSON); this.addDocument("{\"aaa\" : \"bbb\"}"); Query query = ntq("aaa").getLuceneProxyQuery(); final Explanation exp = searcher.explain(query, 0); assertTrue(exp.getValue() != 0); }
@Test public void testExplain() throws IOException { this.addDocuments( doc(token("three", node(1,1)), token("hundred", node(1,2)), token("thirty", node(1,3)), token("three", node(1,4))) ); NodeSpanQuery term1 = new NodeSpanQuery(ntq("three").getQuery()); NodeSpanQuery term2 = new NodeSpanQuery(ntq("thirty").getQuery()); NearSpanQuery near1 = new NearSpanQuery(new SpanQuery[] {term1, term2}, 0, false); Query query = new LuceneProxyNodeQuery(near1); Explanation explanation = searcher.explain(query, 0); assertNotNull(explanation); }