# Faceted search on multiple indices. Is it even possible?

**URL:** <https://discuss.elastic.co/t/faceted-search-on-multiple-indices-is-it-even-possible/10508>\
**Category:** Elasticsearch\
**Created:** [January 25, 2013, 3:51pm UTC](https://discuss.elastic.co/t/faceted-search-on-multiple-indices-is-it-even-possible/10508 "2013-01-25T15:51:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Lecour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremy_lecour/32/1416_2.png) [@Jeremy\_Lecour](https://discuss.elastic.co/u/Jeremy_Lecour)\
**Post date:** [January 25, 2013, 3:51pm UTC](https://discuss.elastic.co/t/faceted-search-on-multiple-indices-is-it-even-possible/10508/1 "2013-01-25T15:51:27Z")

</div>

Hi,

We're trying to use Elasticsearch in a project with a fancy use case.

We have some documents that are sometimes updated, but that are considered  
"static". Let's call them "main documents". They have their own set of  
attributes (ex : author, created\_at, category, …).

We have some other documents that are indexed as they are produced. Let's  
call them children documents. They are related to the main documents (with  
a main\_doc\_id) and also depend on a user's context (user\_id). Imagine they  
are metadata about the parent documents, but specific to the user. Example  
attributes : favorite (boolean), rating, tags, …

We'd like to do a faceted search on the main documents, but those documents  
have to be filtered by attributes of the main document and of the children  
documents. An example search : I want main documents by author Bob, in the  
"sci-fi" category, that I have rated over 5/10. I would like to have the  
main documents returned, and all the facets.

If we use only one index, with 2 types of documents, and a "has child"  
relation between them, we can do all of this.

But (there is always a "but") it doesn't scale !

The "main" documents are quite stable and shared by all users request, so  
they would ideally be in their own index.  
The "children" documents are very volatile (even if they doesn't seem to  
be, in my example) ; they change a lot, and become irrelevant after a few  
hours. They would have been great candidates for a daily rolled index,  
accessed by aliases and routing.

The problem is that the faceted search doesn't work with separate indices,  
because the has\_child needs a single index (as far as I understand).

Does that ring a bell to any of you?  
Do I try to do something crazy?

Thanks for any advice.

--  
Jeremy

--

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 27, 2013, 10:22am UTC](https://discuss.elastic.co/t/faceted-search-on-multiple-indices-is-it-even-possible/10508/2 "2013-01-27T10:22:42Z")

</div>

Yea, you can't combine rolling indices with static "parents". Its either making sure each rolling index has all the parents, or having enough shards so that as you add more children (for a single parent) you won't need a rolling index. No magic answers here sadly...

On Jan 25, 2013, at 4:51 PM, Jérémy Lecour [jeremy.lecour@gmail.com](mailto:jeremy.lecour@gmail.com) wrote:

> Hi,
> 
> We're trying to use Elasticsearch in a project with a fancy use case.
> 
> We have some documents that are sometimes updated, but that are considered "static". Let's call them "main documents". They have their own set of attributes (ex : author, created\_at, category, …).
> 
> We have some other documents that are indexed as they are produced. Let's call them children documents. They are related to the main documents (with a main\_doc\_id) and also depend on a user's context (user\_id). Imagine they are metadata about the parent documents, but specific to the user. Example attributes : favorite (boolean), rating, tags, …
> 
> We'd like to do a faceted search on the main documents, but those documents have to be filtered by attributes of the main document and of the children documents. An example search : I want main documents by author Bob, in the "sci-fi" category, that I have rated over 5/10. I would like to have the main documents returned, and all the facets.
> 
> If we use only one index, with 2 types of documents, and a "has child" relation between them, we can do all of this.
> 
> But (there is always a "but") it doesn't scale !
> 
> The "main" documents are quite stable and shared by all users request, so they would ideally be in their own index.  
> The "children" documents are very volatile (even if they doesn't seem to be, in my example) ; they change a lot, and become irrelevant after a few hours. They would have been great candidates for a daily rolled index, accessed by aliases and routing.
> 
> The problem is that the faceted search doesn't work with separate indices, because the has\_child needs a single index (as far as I understand).
> 
> Does that ring a bell to any of you?  
> Do I try to do something crazy?
> 
> Thanks for any advice.
> 
> --  
> Jeremy
> 
> --

--

---

<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 6, 2017, 2:54am UTC](https://discuss.elastic.co/t/faceted-search-on-multiple-indices-is-it-even-possible/10508/3 "2017-07-06T02:54:27Z")

</div>

Closed on July 6, 2017, 2:54am UTC


