# Priotitizing searching accross multiple Indices

**URL:** https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047
**Category:** Elasticsearch
**Created:** [April 1, 2016, 11:09am UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047 "2016-04-01T11:09:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![soorajhere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soorajhere/32/8396_2.png) [@soorajhere](https://discuss.elastic.co/u/soorajhere)
#### Post date: [April 1, 2016, 11:09am UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/1 "2016-04-01T11:09:52Z")

</div>

Hi All,

I have multiple indices created in my elastic search. I am using 2.1.1 version. of ES.  
My search requirement is like user will enter a keyword and search should happen against all indexes. But i want to prioritize the records returned. I mean ,I need only 10 matching records. From Index A i need 5 record, from index B i need 3 record, and from index C i need 2 record.  
This is max count in case all indices fetch matching results. But in case index B and C doesn't have any matching record, i need all 10 from index A if it has more records. Similarly if there is no matching record from index B, then 8 record from index A and 2 record from index B should be returned.

Is this kind of segregation possible in ES?

---

<div class="post-metadata">

### Author: ![iliasse](https://avatars.discourse-cdn.com/v4/letter/i/22d042/32.png) [@iliasse](https://discuss.elastic.co/u/iliasse)
#### Post date: [April 1, 2016, 12:10pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/2 "2016-04-01T12:10:00Z")

</div>

Hi soorajhere,

I guess that you could do that by adding some logic (by logic i mean code) in Java for example and filter results as you wish. I am not aware of such a built-in feature in Elastic.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 1, 2016, 12:17pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/3 "2016-04-01T12:17:46Z")

</div>

I am not aware of any way of doing this with a single query either, but you could send 3 separate queries, each returning 10 results, as part of a [multi search request](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) and then select the ones to use at the application layer.

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [April 1, 2016, 3:30pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/4 "2016-04-01T15:30:01Z")

</div>

I think index boost would help you. Not sure it will allow you to do exactly what you need, but something along those lines for sure. It is not a very popular feature but it's there: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-index-boost.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-index-boost.html) .

Cheers  
Luca

---

<div class="post-metadata">

### Author: ![soorajhere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soorajhere/32/8396_2.png) [@soorajhere](https://discuss.elastic.co/u/soorajhere)
#### Post date: [April 2, 2016, 5:32pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/5 "2016-04-02T17:32:14Z")

</div>

Hi illiasse,

Thank you for your reply.  
I have created a wcf wrapper service in .net and is calling ElasticSearch REST API from this service. I also had similar thought of retrieving all results from ES and then do the filtering from .net code. But the search query which I use is a single multi\_match query and I mention fields from multiple indexes in it. Also the search i need is a phrase\_prefix search and i limit size to 10 in the query.  
As you mentioned, if i do the filtering from .net code, i might have to get all search results(remove size from query?) from ES instead of limiting it to 10, right? I think ES by default return 10 hits, and if more results are required, we need to mention size value. But how can we have a particular value for size upfront? What if more matching search records are present? OR is it like i need to provide a huge number say, 10K or something?

---

<div class="post-metadata">

### Author: ![soorajhere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soorajhere/32/8396_2.png) [@soorajhere](https://discuss.elastic.co/u/soorajhere)
#### Post date: [April 2, 2016, 5:35pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/6 "2016-04-02T17:35:58Z")

</div>

Hi Christian\_Dahlqvist ,  
Thank you for your reply.  
Is it a good idea to hit ES server multiple times with different search query? I thought performance will degrade using this method, so was trying to use fields property in the search query and mention fields from multiple indices in the query.

---

<div class="post-metadata">

### Author: ![soorajhere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soorajhere/32/8396_2.png) [@soorajhere](https://discuss.elastic.co/u/soorajhere)
#### Post date: [April 2, 2016, 5:37pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/7 "2016-04-02T17:37:36Z")

</div>

Hi Luca Cavanna,

Thank you for your reply. I will give a try with index boost.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:02pm UTC](https://discuss.elastic.co/t/priotitizing-searching-accross-multiple-indices/46047/8 "2017-07-05T23:02:58Z")

</div>


