Below is terms query with _msearch
. But its not giving all result.As of now, it only return result for 4161
even though data exists for 4402
as well.
please suggest solution.
GET _msearch
{ "index": ["index1", "index2", "index3"]}
{"query": {"terms": {"user_id": [4161,4402] } }}
type of user_id is long
You either need to increase the size
parameter or sort the data differently. By default only 10 hits come back from a search query and it might well be the case that the first 10 documents being returned are all for user_id: 4161
.
GET _msearch
{ "index": ["index1", "index2", "index3"]}
{"size": 100, "query": {"terms": {"user_id": [4161,4402] } }}
The terms
query is an OR query, i.e. terms: [4161,4402]
is equivalent to term: 4161 OR term: 4402
.
Another way since you're using _msearch
is to send one query per index, since you'll be returning more data, you might be lucky and get data for both users.
GET _msearch
{ "index": "index1"}
{"query": {"terms": {"user_id": [4161,4402] } }}
{ "index": "index2"}
{"query": {"terms": {"user_id": [4161,4402] } }}
{ "index": "index3"}
{"query": {"terms": {"user_id": [4161,4402] } }}