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
+9.2k Mac OSX : Get a process/daemon status information
+10.6k Golang : Get UDP client IP address and differentiate clients by port number
+13.7k Golang : concatenate(combine) strings
+8k Golang : Qt splash screen with delay example
+9.5k Golang : ffmpeg with os/exec.Command() returns non-zero status
+10.8k Golang : Create S3 bucket with official aws-sdk-go package
+9.5k Golang : interface - when and where to use examples
+9.5k Golang : Qt get screen resolution and display on center example
+6.5k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+5.1k Unix/Linux : How to archive and compress entire directory ?
+19.8k Golang : Compare floating-point numbers
+6.3k Golang : Combine slices of complex numbers and operation example