API Requesting all documents in a certain range

(Thund3 R) #1

Good afternoon!
How to correctly make a request to the elastic to get all the documents that fit the query for example: "query": { "bool": { "must": [ { "exists": { "field": "somefield" } } ], "filter": [ { "range": { "timestamp": { "gte": "2018-01-10 15:20:47.381" } } } ] } }, "_source": [ "somefield", "source" ] }

If I make a simple query, it prints out only with the default "size" value of 10, and how to do it to display all the values if you do not know the number of documents in advance?

(David Pilato) #2

If your goal is to export thousands of records you can use the scrolll API which is built for that.

(Thund3 R) #3

Thank you for your advice!
It fits perfectly! Will be using helpers from elasticsearch-py module ))

To not create a new post - Ill ask again here... In what order to make a query in this situation: I want make a query by the presence of a certain field, but for a certain period, and then aggregate these data for example by source. Is this wright?"query": { "bool": { "must": [{"exists": {"field": "some_field"} } ], "filter": [{ "range": {timestamp": {"gte": "2018-01-10 15:20:47.381"}, "aggregations": {"the_name": {"terms": {"field": "source"}}}
Thank you!

(David Pilato) #4

I'd put also the exists in the filter part. So probably something like:

                     "gte":"2018-01-10 15:20:47.381"

(Thund3 R) #5

Thank you very much!!!

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.