Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 947 Bytes

explain.md

File metadata and controls

35 lines (30 loc) · 947 Bytes

Explain

The explain request allows us to see why a document would or would not be included in a query. This is useful to see why queries are not performing as expected.

The format is simple. Specify the index and id of the document, and attach a query from the queryDSL.

val resp = client.execute {
  explain("beer", "8").query(termQuery("name","budweiser"))
}

Which would return something like

{
  "ok" : true,
  "matches" : true,
  "explanation" : {
    "value" : 0.15342641,
    "description" : "fieldWeight(name:budweiser in 0), product of:",
    "details" : [ {
      "value" : 1.0,
      "description" : "tf(termFreq(name:budweiser)=1)"
    }, {
      "value" : 0.30685282,
      "description" : "idf(docFreq=1, maxDocs=1)"
    }, {
      "value" : 0.5,
      "description" : "fieldNorm(field=name, doc=0)"
    } ]
  }
}