uri-request.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/tweet/_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. "failed" : 0
  23. },
  24. "hits":{
  25. "total" : 1,
  26. "max_score": 1.3862944,
  27. "hits" : [
  28. {
  29. "_index" : "twitter",
  30. "_type" : "tweet",
  31. "_id" : "0",
  32. "_score": 1.3862944,
  33. "_source" : {
  34. "user" : "kimchy",
  35. "date" : "2009-11-15T14:12:12",
  36. "message" : "trying out Elasticsearch",
  37. "likes": 0
  38. }
  39. }
  40. ]
  41. }
  42. }
  43. --------------------------------------------------
  44. // TESTRESPONSE[s/"took": 62/"took": "$body.took"/]
  45. [float]
  46. === Parameters
  47. The parameters allowed in the URI are:
  48. [cols="<,<",options="header",]
  49. |=======================================================================
  50. |Name |Description
  51. |`q` |The query string (maps to the `query_string` query, see
  52. <<query-dsl-query-string-query,_Query String
  53. Query_>> for more details).
  54. |`df` |The default field to use when no field prefix is defined within the
  55. query.
  56. |`analyzer` |The analyzer name to be used when analyzing the query string.
  57. |`analyze_wildcard` |Should wildcard and prefix queries be analyzed or
  58. not. Defaults to `false`.
  59. |`default_operator` |The default operator to be used, can be `AND` or
  60. `OR`. Defaults to `OR`.
  61. |`lenient` |If set to true will cause format based failures (like
  62. providing text to a numeric field) to be ignored. Defaults to false.
  63. |`explain` |For each hit, contain an explanation of how scoring of the
  64. hits was computed.
  65. |`_source`|Set to `false` to disable retrieval of the `_source` field. You can also retrieve
  66. part of the document by using `_source_include` & `_source_exclude` (see the <<search-request-source-filtering, request body>>
  67. documentation for more details)
  68. |`stored_fields` |The selective stored fields of the document to return for each hit,
  69. comma delimited. Not specifying any value will cause no fields to return.
  70. |`sort` |Sorting to perform. Can either be in the form of `fieldName`, or
  71. `fieldName:asc`/`fieldName:desc`. The fieldName can either be an actual
  72. field within the document, or the special `_score` name to indicate
  73. sorting based on scores. There can be several `sort` parameters (order
  74. is important).
  75. |`track_scores` |When sorting, set to `true` in order to still track
  76. scores and return them as part of each hit.
  77. |`timeout` |A search timeout, bounding the search request to be executed
  78. within the specified time value and bail with the hits accumulated up to
  79. that point when expired. Defaults to no timeout.
  80. |`terminate_after` |The maximum number of documents to collect for
  81. each shard, upon reaching which the query execution will terminate early.
  82. If set, the response will have a boolean field `terminated_early` to
  83. indicate whether the query execution has actually terminated_early.
  84. Defaults to no terminate_after.
  85. |`from` |The starting from index of the hits to return. Defaults to `0`.
  86. |`size` |The number of hits to return. Defaults to `10`.
  87. |`search_type` |The type of the search operation to perform. Can be
  88. `dfs_query_then_fetch` or `query_then_fetch`.
  89. Defaults to `query_then_fetch`. See
  90. <<search-request-search-type,_Search Type_>> for
  91. more details on the different types of search that can be performed.
  92. |=======================================================================