-
Notifications
You must be signed in to change notification settings - Fork 0
Search API
ignacio-alorre edited this page May 23, 2019
·
6 revisions
The search API allows you to execute a search query and get back search hits that match the query. The query can either be provided using a simple query string as a parameter, or using a request body.
All search APIs can be applied across multiple types within an index, and across multiple indices with support for the multi-index syntax.
For example, we can search on all documents across all types within the twitter index:
GET /twitter/_search?q=user:kimchyWe can also search within specific types, for example tweet and user:
GET /twitter/tweet,user/_search?q=user:kimchyWe can also search all tweets with a certain tag across several indices (for example, when each user has his own index):
GET /twitter/tweet/_search
{
"query" : {
"term" : { "user" : "kimchy" }
}
}GET twitter/tweet/_search?q=user:kimchyAnd here is a sample response:
{
"took": 1,
"timed_out": false,
"_shards":{
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits":{
"total" : 1,
"max_score": 1.3862944,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "0",
"_score": 1.3862944,
"_source" : {
"user" : "kimchy",
"message": "trying out Elasticsearch",
"date" : "2009-11-15T14:12:12",
"likes" : 0
}
}
]
}
}