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
+11k Android Studio : Highlight ImageButton when pressed on example
+11.7k Android Studio : Password input and reveal password example
+21k Golang : Repeat a character by multiple of x factor
+8.7k Golang : Sort and reverse sort a slice of floats
+13.6k Golang : Accurate and reliable decimal calculations
+31.2k Golang : How to check if a date is within certain range?
+9.6k Golang : Create Temporary File
+4k Google : Block or disable caching of your website content
+5.1k Golang : Missing Subversion command
+8.4k Golang : Accessing content anonymously with Tor
+3.5k Javascript : Detect when console is activated and do something about it
+7.9k Golang : Take screen shot of browser with JQuery example