parent
0509465a9e
commit
cb5e9d3bee
|
@ -1,7 +1,7 @@
|
|||
[[search]]
|
||||
== Search APIs
|
||||
|
||||
Most search APIs support <<search-multi-index,multi-target syntax>>, with the
|
||||
Most search APIs support <<multi-index,multi-target syntax>>, with the
|
||||
exception of the <<search-explain>> endpoints.
|
||||
|
||||
[discrete]
|
||||
|
|
|
@ -600,107 +600,6 @@ Key is the field name. Value is the value for the field.
|
|||
[[search-search-api-example]]
|
||||
==== {api-examples-title}
|
||||
|
||||
[[search-api-specific-ex]]
|
||||
===== Search a single data stream or index using the `q` query parameter
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /my-index-000001/_search?q=user.id:kimchy
|
||||
----
|
||||
// TEST[setup:my_index]
|
||||
|
||||
The API returns the following response:
|
||||
|
||||
[source,console-result]
|
||||
----
|
||||
{
|
||||
"took": 5,
|
||||
"timed_out": false,
|
||||
"_shards": {
|
||||
"total": 1,
|
||||
"successful": 1,
|
||||
"skipped": 0,
|
||||
"failed": 0
|
||||
},
|
||||
"hits": {
|
||||
"total": {
|
||||
"value": 1,
|
||||
"relation": "eq"
|
||||
},
|
||||
"max_score": 1.3862942,
|
||||
"hits": [
|
||||
{
|
||||
"_index": "my-index-000001",
|
||||
"_type" : "_doc",
|
||||
"_id": "0",
|
||||
"_score": 1.3862942,
|
||||
"_source": {
|
||||
"@timestamp": "2099-11-15T14:12:12",
|
||||
"http": {
|
||||
"request": {
|
||||
"method": "get"
|
||||
},
|
||||
"response": {
|
||||
"status_code": 200,
|
||||
"bytes": 1070000
|
||||
},
|
||||
"version": "1.1"
|
||||
},
|
||||
"source": {
|
||||
"ip": "127.0.0.1"
|
||||
},
|
||||
"message": "GET /search HTTP/1.1 200 1070000",
|
||||
"user": {
|
||||
"id": "kimchy"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
----
|
||||
// TESTRESPONSE[s/"took": 5/"took": $body.took/]
|
||||
|
||||
[[search-multi-index]]
|
||||
===== Search several data streams and indices using the `q` query parameter
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /my-index-000001,my-index-000002/_search?q=user.id:kimchy
|
||||
----
|
||||
// TEST[setup:my_index]
|
||||
// TEST[s/^/PUT my-index-000002\n/]
|
||||
|
||||
[[search-api-all-ex]]
|
||||
===== Search a cluster using the `q` query parameter
|
||||
|
||||
To search all data streams and indices in a cluster,
|
||||
omit the `<target>` parameter.
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /_search?q=user.id:kimchy
|
||||
----
|
||||
// TEST[setup:my_index]
|
||||
|
||||
Alternatively,
|
||||
you can use the `_all` or `*` value in the `<target>` parameter.
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /_all/_search?q=user.id:kimchy
|
||||
----
|
||||
// TEST[setup:my_index]
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /*/_search?q=user.id:kimchy
|
||||
----
|
||||
// TEST[setup:my_index]
|
||||
|
||||
[[search-request-body-api-example]]
|
||||
===== Search using the `query` request body parameter
|
||||
|
||||
[source,console]
|
||||
----
|
||||
GET /my-index-000001/_search
|
||||
|
|
Loading…
Reference in New Issue