Elastic Search : Return all records (higher than default 10)
Problem :
You only get 10 results from elastic search query and you suspected that there should be more results return by Elastic Search. How to increase or show all the matching results returned by Elastic Search?
Diagnostic :
From the official Elastic Search documentation - URI search request. By default settings, Elastic Search query will only return 10 rows.
size - The number of hits to return. Defaults to 10.
Solution :
You will need to increase the number of row returned with the size
parameter.
For my own implementation in SocketLoop.com's tag search. I just specify the size
parameter with a very large number. Bigger than my dataset.
This is taken from SocketLoop PHP source code :
// Elastic Search default return size is 10, will just use 9999
$searchquery = '{
"size" : 9999,
"query" : {
"match" : { "tags" : "'.$searchkey.'" }
}
}';
or general example :
http://127.0.0.1:9200/indexname/_search/?size=9999&&q=*:*&pretty=1
See also : PHP : How to parse ElasticSearch JSON ?
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+25.3k Golang : Convert uint value to string type
+8.9k Golang : Sort lines of text example
+5.3k Golang : Calculate half life decay example
+11.3k CodeIgniter : How to check if a session exist in PHP?
+13.1k Swift : Convert (cast) Int to String ?
+13.5k Golang : Increment string example
+8.3k Golang : Add build version and other information in executables
+30.1k Golang : Get time.Duration in year, month, week or day
+17.6k Golang : Clone with pointer and modify value
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+14.5k Golang : Find network of an IP address
+13.9k Golang : Convert spaces to tabs and back to spaces example