request-body.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [[search-request-body]]
  2. == Request Body Search
  3. The search request can be executed with a search DSL, which includes the
  4. <<query-dsl,Query DSL>>, within its body. Here is an
  5. example:
  6. [source,js]
  7. --------------------------------------------------
  8. $ curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
  9. "query" : {
  10. "term" : { "user" : "kimchy" }
  11. }
  12. }
  13. '
  14. --------------------------------------------------
  15. And here is a sample response:
  16. [source,js]
  17. --------------------------------------------------
  18. {
  19. "_shards":{
  20. "total" : 5,
  21. "successful" : 5,
  22. "failed" : 0
  23. },
  24. "hits":{
  25. "total" : 1,
  26. "hits" : [
  27. {
  28. "_index" : "twitter",
  29. "_type" : "tweet",
  30. "_id" : "1",
  31. "_source" : {
  32. "user" : "kimchy",
  33. "postDate" : "2009-11-15T14:12:12",
  34. "message" : "trying out Elasticsearch"
  35. }
  36. }
  37. ]
  38. }
  39. }
  40. --------------------------------------------------
  41. [float]
  42. === Parameters
  43. [horizontal]
  44. `timeout`::
  45. A search timeout, bounding the search request to be executed within the
  46. specified time value and bail with the hits accumulated up to that point
  47. when expired. Defaults to no timeout. See <<time-units>>.
  48. `from`::
  49. The starting from index of the hits to return. Defaults to `0`.
  50. `size`::
  51. The number of hits to return. Defaults to `10`. If you do not care about
  52. getting some hits back but only about the number of matches and/or
  53. aggregations, setting the value to `0` will help performance.
  54. `search_type`::
  55. The type of the search operation to perform. Can be
  56. `dfs_query_then_fetch` or `query_then_fetch`.
  57. Defaults to `query_then_fetch`.
  58. See <<search-request-search-type,_Search Type_>> for more.
  59. `request_cache`::
  60. Set to `true` or `false` to enable or disable the caching
  61. of search results for requests where `size` is 0, ie
  62. aggregations and suggestions (no top hits returned).
  63. See <<shard-request-cache>>.
  64. `terminate_after`::
  65. experimental[The API for this feature may change in the future]
  66. The maximum number of documents to collect for each shard,
  67. upon reaching which the query execution will terminate early. If set, the
  68. response will have a boolean field `terminated_early` to indicate whether
  69. the query execution has actually terminated_early. Defaults to no
  70. terminate_after.
  71. Out of the above, the `search_type` and the `request_cache` must be passed as
  72. query-string parameters. The rest of the search request should be passed
  73. within the body itself. The body content can also be passed as a REST
  74. parameter named `source`.
  75. Both HTTP GET and HTTP POST can be used to execute search with body. Since not
  76. all clients support GET with body, POST is allowed as well.
  77. include::request/query.asciidoc[]
  78. include::request/from-size.asciidoc[]
  79. include::request/sort.asciidoc[]
  80. include::request/source-filtering.asciidoc[]
  81. include::request/fields.asciidoc[]
  82. include::request/script-fields.asciidoc[]
  83. include::request/fielddata-fields.asciidoc[]
  84. include::request/post-filter.asciidoc[]
  85. include::request/highlighting.asciidoc[]
  86. include::request/rescore.asciidoc[]
  87. include::request/search-type.asciidoc[]
  88. include::request/scroll.asciidoc[]
  89. include::request/preference.asciidoc[]
  90. include::request/explain.asciidoc[]
  91. include::request/version.asciidoc[]
  92. include::request/index-boost.asciidoc[]
  93. include::request/min-score.asciidoc[]
  94. include::request/named-queries-and-filters.asciidoc[]
  95. include::request/inner-hits.asciidoc[]