RKP
RKP

Reputation: 880

Elastic Search size option with multiple indexes

I am trying to fetch data from two indexes of elastic search. I am getting it with the below query.

But, I want 20 data set from each index as results

Is there any provision for this?

Below is my query :

  curl -X POST \
  'http://localhost:9200/index1,index2/_search' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
   "query": {},
   "from": 0,
   "size": 20
  }'

Upvotes: 1

Views: 684

Answers (1)

ibexit
ibexit

Reputation: 3667

Yes, for sure. There is a multi search feature which allows you to send two (or more) search requests (one per index, 10 results each) at once. The response will contain the results/outcome of all queries in the very same order.

Have a look on https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html for more in detail information.

Upvotes: 2

Related Questions