You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Querying: Debugging: How to include Query Explanations

includeExplanations allows to investigate details related to score assigned for each query result.


IDocumentQuery<T> includeExplanations(Reference<Explanations> explanations);


Reference<Explanations> explanationRef = new Reference<>();
List<Product> syrups = session.advanced().documentQuery(Product.class)
    .search("Name", "Syrup")

String[] scoreDetails = explanationRef.value.getExplanations(syrups.get(0).getId());
from Products 
where search(Name, 'Syrup')
include explanations()

Sample explanation:

4.650658 = (MATCH) fieldWeight(search(Name):syrup in 2), product of:
  1 = tf(termFreq(search(Name):syrup)=1)
  4.650658 = idf(docFreq=1, maxDocs=77)
  1 = fieldNorm(field=search(Name), doc=2)