I have already searching this since 2 days now. I use the sense chrome plugin to be able to test my queries but I don't find how to specify on which index he is supposed to search. So my queries search on all the indexes and it isn't easy to use.
I have try the following syntaxes:
GET _search { "query": { "term": { "_index": { "value": "dev_events2" } } } } GET _search { "_index": "dev_events2", "query": { "match_all" : { } } } GET _search { "index": "dev_events2", "query": { "match_all" : { } } }
Regards,
Benjamin V.
Edit I finally have found the answer: just add the index name into the url for the get: localhost:9201/myIndexName
You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .
There are two recommended methods to retrieve selected fields from a search query: Use the fields option to extract the values of fields present in the index mapping. Use the _source option if you need to access the original data that was passed at index time.
To search multiple data streams and indices, add them as comma-separated values in the search API's request path. The following request searches the my-index-000001 and my-index-000002 indices. You can also search multiple data streams and indices using an index pattern.
Elasticsearch will get significant slower if you just add some big number as size, one method to use to get all documents is using scan and scroll ids. The results from this would contain a _scroll_id which you have to query to get the next 100 chunk. This answer needs more updates. search_type=scan is now deprecated.
Heres curl example what works, and allows you to search multiple indexes:
curl 'http://localhost:9200/myindex1,myindex2/_search?q=*'
For single specific index:
curl 'http://localhost:9200/myindex1/_search?q=*'
To find find index names:
curl 'localhost:9200/_cat/indices'
And if you want to search all indexes:
curl 'localhost:9200/_search?pretty'
You can also add the index/type to the GET/PUT/DELETE ... query:
GET index/type/_search { "query": { "bool": { "must": [ { "term": { ... } } ] } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With