Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch return all documents of a given type

I have been searching for a solution to this question for a few days. Use case is to simply see the documents of a particular type only. Usually after googling for a long time I end up with some search queries with wildcards. I have gone through many SO Posts like this, this and elastic documentation also. I tried below urls but without any luck.

curl -XGET 'localhost:9200/analytics/test/_search' -d '
{

   "query" : {
   "match_all" : {}
    }
}'

curl -XGET 'localhost:9200/analytics/test/_search' -d '
{
    "query": {
        "type":{
            "value": "test"
            }
    }
}'

Is there something like a wild card search on a document type to return all documents of that specific doc_type?

like image 673
cutteeth Avatar asked Mar 09 '17 12:03

cutteeth


People also ask

How do I get all documents in Elasticsearch?

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.

How do I view documents in Elasticsearch?

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 .

How do I get all indices in Elasticsearch?

You can query localhost:9200/_status and that will give you a list of indices and information about each.


1 Answers

To get all documents from index analytics from type test just run:

curl -XGET localhost:9200/analytics/test/_search

or

curl -XGET localhost:9200/analytics/test/_search -d '{
    "query": {"match_all" : {}}
}'

If you have count of users more than default size value, you need provide from/size values like described here.

like image 179
cn007b Avatar answered Sep 22 '22 14:09

cn007b