explain.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. [[search-explain]]
  2. == Explain API
  3. The explain api computes a score explanation for a query and a specific
  4. document. This can give useful feedback whether a document matches or
  5. didn't match a specific query.
  6. The `index` and `type` parameters expect a single index and a single
  7. type respectively.
  8. [float]
  9. === Usage
  10. Full query example:
  11. [source,js]
  12. --------------------------------------------------
  13. GET /twitter/tweet/0/_explain
  14. {
  15. "query" : {
  16. "match" : { "message" : "elasticsearch" }
  17. }
  18. }
  19. --------------------------------------------------
  20. // CONSOLE
  21. // TEST[setup:twitter]
  22. This will yield the following result:
  23. [source,js]
  24. --------------------------------------------------
  25. {
  26. "_index" : "twitter",
  27. "_type" : "tweet",
  28. "_id" : "0",
  29. "matched" : true,
  30. "explanation" : {
  31. "value" : 1.55077,
  32. "description" : "sum of:",
  33. "details" : [ {
  34. "value" : 1.55077,
  35. "description" : "weight(message:elasticsearch in 0) [PerFieldSimilarity], result of:",
  36. "details" : [ {
  37. "value" : 1.55077,
  38. "description" : "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  39. "details" : [ {
  40. "value" : 1.3862944,
  41. "description" : "idf(docFreq=1, docCount=5)",
  42. "details" : [ ]
  43. }, {
  44. "value" : 1.1186441,
  45. "description" : "tfNorm, computed from:",
  46. "details" : [
  47. { "value" : 1.0, "description" : "termFreq=1.0", "details" : [ ] },
  48. { "value" : 1.2, "description" : "parameter k1", "details" : [ ] },
  49. { "value" : 0.75, "description" : "parameter b", "details" : [ ] },
  50. { "value" : 5.4, "description" : "avgFieldLength", "details" : [ ] },
  51. { "value" : 4.0, "description" : "fieldLength", "details" : [ ] }
  52. ]
  53. } ]
  54. } ]
  55. }, {
  56. "value" : 0.0,
  57. "description" : "match on required clause, product of:",
  58. "details" : [ {
  59. "value" : 0.0,
  60. "description" : "# clause",
  61. "details" : [ ]
  62. }, {
  63. "value" : 1.0,
  64. "description" : "_type:tweet, product of:",
  65. "details" : [
  66. { "value" : 1.0, "description" : "boost", "details" : [ ] },
  67. { "value" : 1.0, "description" : "queryNorm", "details" : [ ] }
  68. ]
  69. } ]
  70. } ]
  71. }
  72. }
  73. --------------------------------------------------
  74. // TESTRESPONSE
  75. There is also a simpler way of specifying the query via the `q`
  76. parameter. The specified `q` parameter value is then parsed as if the
  77. `query_string` query was used. Example usage of the `q` parameter in the
  78. explain api:
  79. [source,js]
  80. --------------------------------------------------
  81. GET /twitter/tweet/0/_explain?q=message:search
  82. --------------------------------------------------
  83. // CONSOLE
  84. // TEST[setup:twitter]
  85. This will yield the same result as the previous request.
  86. [float]
  87. === All parameters:
  88. [horizontal]
  89. `_source`::
  90. Set to `true` to retrieve the `_source` of the document explained. You can also
  91. retrieve part of the document by using `_source_include` & `_source_exclude` (see <<get-source-filtering,Get API>> for more details)
  92. `stored_fields`::
  93. Allows to control which stored fields to return as part of the
  94. document explained.
  95. `routing`::
  96. Controls the routing in the case the routing was used
  97. during indexing.
  98. `parent`::
  99. Same effect as setting the routing parameter.
  100. `preference`::
  101. Controls on which shard the explain is executed.
  102. `source`::
  103. Allows the data of the request to be put in the query
  104. string of the url.
  105. `q`::
  106. The query string (maps to the query_string query).
  107. `df`::
  108. The default field to use when no field prefix is defined within
  109. the query. Defaults to _all field.
  110. `analyzer`::
  111. The analyzer name to be used when analyzing the query
  112. string. Defaults to the analyzer of the _all field.
  113. `analyze_wildcard`::
  114. Should wildcard and prefix queries be analyzed or
  115. not. Defaults to false.
  116. `lowercase_expanded_terms`::
  117. Should terms be automatically lowercased
  118. or not. Defaults to true.
  119. `lenient`::
  120. If set to true will cause format based failures (like
  121. providing text to a numeric field) to be ignored. Defaults to false.
  122. `default_operator`::
  123. The default operator to be used, can be AND or
  124. OR. Defaults to OR.