Skip to main content

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(out Explanations explanations);

Example

var syrups = session.Advanced.DocumentQuery<Product>()
.IncludeExplanations(out Explanations explanations)
.Search(x => x.Name, "Syrup")
.ToList();

string[] scoreDetails = explanations.GetExplanations(syrups[0].Id);

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)