I'm searching an Solr index with SolrJ and trying to get the Lucene explanation for logging it for further use.
The code goes like this:
SolrServer server = new CommonsHttpSolrServer("solr_url");
SolrQuery solrquery = new SolrQuery();
solrquery.set("fl", "score, id"); // id is a String field
solrquery.set("rows", "1000");
solrquery.set("debugQuery", "on");
solrquery.setQuery("query words here");
try {
QueryResponse response = server.query(solrquery);
SolrDocumentList docs = response.getResults();
Iterator<SolrDocument> dociterator = docs.iterator();
while (dociterator.hasNext())
{
SolrDocument doc = dociterator.next();
String id = (String) doc.getFirstValue(idfield);
Float relevance = (Float) doc.getFirstValue("score");
String explanation = ???;
}
} catch (SolrServerException e) {
e.printStackTrace();
}
I figured that response.getEplainMap() would contain a map with the value like response.getEplainMap().get(id) , but it seems that the explainmap contains only the key null with the value of the last found document.
Any ideas how to get the correct explanation?