BIS Tech
BIS Tech

Reputation: 19434

Multiple queries with limitation in Elasticsearch

I want to get two types of items in one query. Is it possible to do it?

Items should be 3 * 2 items. it means all items are six. 3 items in isFamous:true and 3 items in isBest:true

Upvotes: 0

Views: 208

Answers (1)

Evaldas Buinauskas
Evaldas Buinauskas

Reputation: 14077

You could use Multi Search API:

POST /_msearch
{"index": "your-index-name"}
{"size": 3, "query": { "term": { "isFamous": { "value": "true" } } } }
{"index": "your-index-name"}
{"size": 3, "query": {"term": { "isBest": { "value": "true" } } } }

This will issue two queries and bring their results in a single response. Another way would be using aggregations.

Upvotes: 3

Related Questions