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.

Syntax

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

Example

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

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)