I am new to Elastic Search. Is there any way to get all the search results for a search keyword? Elastic Search is limited to 10 or else we can set the size but we need to get the size??
Asked
Active
Viewed 1.3k times
9
-
1I would recoment to use scroll search for fetching all records(like paging). http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html – Emil Jun 25 '14 at 11:09
3 Answers
16
Yes, the default number of search results is 10.
You need to set the size
parameter on the query.
I don't think you an say "all results", though, there must always be a size limit.

skaffman
- 398,947
- 96
- 818
- 769
-
-
@skaffman see if i search an keyword `example` if it is in 200 document i need to display the 200 results .. – raagavan Feb 14 '11 at 10:24
-
is there is any way to make field collapase like solr `http://blog.jteam.nl/2009/10/20/result-grouping-field-collapsing-with-solr/` – raagavan Feb 14 '11 at 10:43
-
@raagavan no. but you could look into chield parent stuff: http://www.elasticsearch.org/guide/reference/query-dsl/has-child-filter.html – Karussell Jun 27 '11 at 21:34
-
@raagavan if you need allways all documents (why would you??) consider scan search: http://www.elasticsearch.org/blog/2011/03/24/new-search-types.html – Karussell Jun 27 '11 at 21:36
-
what's the max accepted value for size? can't find it in the docs and the c# int.MaxValue fails with brio. – lnaie Dec 12 '14 at 15:15
4
If you use the JAVA API you can simple get the total hit number from the SearchResponse
SearchRequestBuilder srb = ..
SearchResponse sr = srb.execute().actionGet();
long totalHits = sr.getHits().getTotalHits();

matthias
- 711
- 4
- 15
0
You can do this in couple of steps using some code
- Fix a size say
1000
and get all 1000 records. - Identify from
hits.total
whether size is smaller than 1000. (if small then you got all the records :) ) - Otherwise use from and size to provide
1001
in from andtotal
as size from previous query to get full result.

AabinGunz
- 12,109
- 54
- 146
- 218