IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
URI Search
editURI Search
editSpecifies search criteria as query parameters in the request URI.
GET twitter/_search?q=user:kimchy
Request
editGET /<index>/_search?q=<parameter>
Description
editYou can use query parameters to define your search criteria directly in the request URI, rather than in the request body. Request URI searches do not support the full Elasticsearch Query DSL, but are handy for testing.
Path parameters
edit-
<index>
- (Optional, string) Comma-separated list or wildcard expression of index names used to limit the request.
Query parameters
edit-
allow_partial_search_results
-
(Optional, boolean) Set to
false
to fail the request if only partial results are available. Defaults totrue
, which returns partial results in the event of timeouts or partial failures You can override the default behavior for all requests by settingsearch.default_allow_partial_results
tofalse
in the cluster settings. -
analyze_wildcard
-
(Optional, boolean) If
true
, wildcard and prefix queries are analyzed. Defaults tofalse
. -
analyzer
- (Optional, string) Analyzer to use for the query string.
-
batched_reduce_size
- (Optional, integer) The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
-
default_operator
-
(Optional, string) The default operator for query string query: AND or OR.
Defaults to
OR
. -
df
- (Optional, string) Field to use as default where no field prefix is given in the query string.
-
explain
- (Optional, string) For each hit, include an explanation of how the score was computed.
-
from
-
(Optional, integer) Starting document offset. Defaults to
0
. -
lenient
-
(Optional, boolean) If
true
, format-based query failures (such as providing text to a numeric field) will be ignored. Defaults tofalse
. -
q
- (Optional, string) Query in the Lucene query string syntax.
-
search_type
-
(Optional, string) The type of the search operation. Available options:
-
query_then_fetch
-
dfs_query_then_fetch
-
-
size
-
(Optional, integer) The number of hits to return. Defaults to
10
. -
_source
-
(Optional, string) True or false to return the
_source
field or not, or a list of fields to return. -
_source_excludes
-
(Optional, string) A list of fields to exclude from the returned
_source
field. -
_source_includes
-
(Optional, string) A list of fields to extract and return from the
_source
field. -
stored_fields
- (Optional, string) The selective stored fields of the document to return for each hit, comma delimited. Not specifying any value will cause no fields to return.
-
sort
-
(Optional, string) Sorting to perform. Can either be in the form of
fieldName
, orfieldName:asc
/fieldName:desc
. The fieldName can either be an actual field within the document, or the special_score
name to indicate sorting based on scores. There can be severalsort
parameters (order is important). -
track_scores
-
(Optional, boolean) When sorting, set to
true
in order to still track scores and return them as part of each hit. -
track_total_hits
-
(Optional, integer) Defaults to
10,000
. Set tofalse
in order to disable the tracking of the total number of hits that match the query. It also accepts an integer which in this case represents the number of hits to count accurately. (See the request body documentation for more details). -
timeout
- (Optional, time units) A search timeout, bounding the search request to be executed within the specified time value and bail with the hits accumulated up to that point when expired. Defaults to no timeout.
-
terminate_after
- (Optional, integer) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
Examples
editGET twitter/_search?q=user:kimchy
The API returns the following response:
{ "timed_out": false, "took": 62, "_shards":{ "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits":{ "total" : { "value": 1, "relation": "eq" }, "max_score": 1.3862944, "hits" : [ { "_index" : "twitter", "_type" : "_doc", "_id" : "0", "_score": 1.3862944, "_source" : { "user" : "kimchy", "date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch", "likes": 0 } } ] } }