uri-request.asciidoc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. [[search-uri-request]]
  2. == URI Search
  3. A search request can be executed purely using a URI by providing request
  4. parameters. Not all search options are exposed when executing a search
  5. using this mode, but it can be handy for quick "curl tests". Here is an
  6. example:
  7. [source,js]
  8. --------------------------------------------------
  9. GET twitter/_search?q=user:kimchy
  10. --------------------------------------------------
  11. // CONSOLE
  12. // TEST[setup:twitter]
  13. And here is a sample response:
  14. [source,js]
  15. --------------------------------------------------
  16. {
  17. "timed_out": false,
  18. "took": 62,
  19. "_shards":{
  20. "total" : 1,
  21. "successful" : 1,
  22. "skipped" : 0,
  23. "failed" : 0
  24. },
  25. "hits":{
  26. "total" : 1,
  27. "max_score": 1.3862944,
  28. "hits" : [
  29. {
  30. "_index" : "twitter",
  31. "_type" : "_doc",
  32. "_id" : "0",
  33. "_score": 1.3862944,
  34. "_source" : {
  35. "user" : "kimchy",
  36. "date" : "2009-11-15T14:12:12",
  37. "message" : "trying out Elasticsearch",
  38. "likes": 0
  39. }
  40. }
  41. ]
  42. }
  43. }
  44. --------------------------------------------------
  45. // TESTRESPONSE[s/"took": 62/"took": "$body.took"/]
  46. [float]
  47. === Parameters
  48. The parameters allowed in the URI are:
  49. [cols="<,<",options="header",]
  50. |=======================================================================
  51. |Name |Description
  52. |`q` |The query string (maps to the `query_string` query, see
  53. <<query-dsl-query-string-query,_Query String
  54. Query_>> for more details).
  55. |`df` |The default field to use when no field prefix is defined within the
  56. query.
  57. |`analyzer` |The analyzer name to be used when analyzing the query string.
  58. |`analyze_wildcard` |Should wildcard and prefix queries be analyzed or
  59. not. Defaults to `false`.
  60. |`batched_reduce_size` | The number of shard results that should be reduced
  61. at once on the coordinating node. This value should be used as a protection
  62. mechanism to reduce the memory overhead per search request if the potential
  63. number of shards in the request can be large.
  64. |`default_operator` |The default operator to be used, can be `AND` or
  65. `OR`. Defaults to `OR`.
  66. |`lenient` |If set to true will cause format based failures (like
  67. providing text to a numeric field) to be ignored. Defaults to false.
  68. |`explain` |For each hit, contain an explanation of how scoring of the
  69. hits was computed.
  70. |`_source`|Set to `false` to disable retrieval of the `_source` field. You can also retrieve
  71. part of the document by using `_source_include` & `_source_exclude` (see the <<search-request-source-filtering, request body>>
  72. documentation for more details)
  73. |`stored_fields` |The selective stored fields of the document to return for each hit,
  74. comma delimited. Not specifying any value will cause no fields to return.
  75. |`sort` |Sorting to perform. Can either be in the form of `fieldName`, or
  76. `fieldName:asc`/`fieldName:desc`. The fieldName can either be an actual
  77. field within the document, or the special `_score` name to indicate
  78. sorting based on scores. There can be several `sort` parameters (order
  79. is important).
  80. |`track_scores` |When sorting, set to `true` in order to still track
  81. scores and return them as part of each hit.
  82. |`track_total_hits` |Set to `false` in order to disable the tracking
  83. of the total number of hits that match the query.
  84. (see <<index-modules-index-sorting,_Index Sorting_>> for more details).
  85. Defaults to true.
  86. |`timeout` |A search timeout, bounding the search request to be executed
  87. within the specified time value and bail with the hits accumulated up to
  88. that point when expired. Defaults to no timeout.
  89. |`terminate_after` |The maximum number of documents to collect for
  90. each shard, upon reaching which the query execution will terminate early.
  91. If set, the response will have a boolean field `terminated_early` to
  92. indicate whether the query execution has actually terminated_early.
  93. Defaults to no terminate_after.
  94. |`from` |The starting from index of the hits to return. Defaults to `0`.
  95. |`size` |The number of hits to return. Defaults to `10`.
  96. |`search_type` |The type of the search operation to perform. Can be
  97. `dfs_query_then_fetch` or `query_then_fetch`.
  98. Defaults to `query_then_fetch`. See
  99. <<search-request-search-type,_Search Type_>> for
  100. more details on the different types of search that can be performed.
  101. |`allow_partial_search_results` |Set to `false` to return an overall failure if the request would produce
  102. partial results. Defaults to true, which will allow partial results in the case of timeouts
  103. or partial failures. This default can be controlled using the cluster-level setting
  104. `search.default_allow_partial_results`.
  105. |=======================================================================