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
+5.5k Golang : Find relative luminance or color brightness
+9.6k Golang : How to display image file or expose CSS, JS files from localhost?
+22k Golang : Convert(cast) string to uint8 type and back to string
+9.5k Golang : Forwarding a local port to a remote server example
+12.5k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+7.7k Golang : Convert(cast) string to int64
+16k Golang : Check if a directory exist or not
+3.5k Unix/Linux/MacOSx : How to remove an environment variable ?
+4.1k Golang : Measure execution time for a function
+16.6k Golang : How to get struct tag and use field name to retrieve data?
+5.5k Golang : Check from web if Go application is running or not
+8.4k Generate salted password with OpenSSL example