2013-08-28 19:24:34 -04:00
[[search-search]]
== Search
2016-05-10 03:39:42 -04:00
The search API allows you to execute a search query and get back search hits
2013-08-28 19:24:34 -04:00
that match the query. The query can either be provided using a simple
<<search-uri-request,query string as a parameter>>, or using a
<<search-request-body,request body>>.
2018-10-19 12:47:34 -04:00
["float",id="search-multi-index"]
=== Multi-Index
2013-08-28 19:24:34 -04:00
2018-10-19 12:47:34 -04:00
All search APIs can be applied across multiple indices with support for
the <<multi-index,multi index syntax>>. For
2018-04-13 03:07:51 -04:00
example, we can search on all documents within the twitter index:
2013-08-28 19:24:34 -04:00
[source,js]
--------------------------------------------------
2016-09-14 11:23:25 -04:00
GET /twitter/_search?q=user:kimchy
2013-08-28 19:24:34 -04:00
--------------------------------------------------
2016-09-14 11:23:25 -04:00
// CONSOLE
// TEST[setup:twitter]
2013-08-28 19:24:34 -04:00
2018-10-19 12:47:34 -04:00
We can also search all documents with a certain tag across several indices
(for example, when there is one index per user):
2013-08-28 19:24:34 -04:00
[source,js]
--------------------------------------------------
2017-12-14 11:47:53 -05:00
GET /kimchy,elasticsearch/_search?q=tag:wow
2013-08-28 19:24:34 -04:00
--------------------------------------------------
2016-09-14 11:23:25 -04:00
// CONSOLE
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
2013-08-28 19:24:34 -04:00
2018-10-19 12:47:34 -04:00
Or we can search across all available indices using `_all`:
2013-08-28 19:24:34 -04:00
[source,js]
2018-10-19 12:47:34 -04:00
---------------------------------------------------
2017-12-14 11:47:53 -05:00
GET /_all/_search?q=tag:wow
2018-10-19 12:47:34 -04:00
---------------------------------------------------
2016-09-14 11:23:25 -04:00
// CONSOLE
2019-04-29 08:28:03 -04:00
// TEST[setup:twitter]
[float]
[[search-partial-responses]]
=== Partial responses
To ensure fast responses, the search API will respond with partial results if one or more shards fail. See <<shard-failures, Shard failures>> for more information.