# Advice on design & query

**URL:** <https://discuss.elastic.co/t/advice-on-design-query/182743>\
**Category:** Elasticsearch\
**Created:** [May 25, 2019, 5:54am UTC](https://discuss.elastic.co/t/advice-on-design-query/182743 "2019-05-25T05:54:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aco\_Strkalj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aco_strkalj/32/46838_2.png) [@Aco\_Strkalj](https://discuss.elastic.co/u/Aco_Strkalj)\
**Post date:** [May 25, 2019, 5:54am UTC](https://discuss.elastic.co/t/advice-on-design-query/182743/1 "2019-05-25T05:54:20Z")

</div>

Hi everyone I just started exploring ES it seems like a great solution to my search needs. However I am stuck at figuring out how to apply it with my current database storage design.

I have 2 tables, one called ' **titles**' and another called ' **media**' which the titles are part of.

My titles table is simple, it has 5 fields, which are:

1. id
2. media\_id
3. name
4. language
5. type

ID is the serial primary key, media\_id points to the primary key in the media table which contains additional information on the media (such as type(movie/tv), year, season, status, etc.). The name is the name the title's text. Language specifies the language of the title and type specifies if the title is a synonym or an official title and such.

There are several titles that point to the same media. Currently I use Elasticsearch’s to index every row in titles. And it does provide me with great results when I search. However it returns the title's ID. I'm wondering if there is a way of grouping the results so instead of providing me with the title ID, it would provide me with the media\_id.

Currently when I perform a search the top 5 results point to the same media\_id which return as 5 unique title IDs. Which forces me to query my database to to get the media\_id for the title ID provided. is there a better way of implementing this for my use case? I read in the docs about a 'parent' I can create for my indexes. Not sure if that is what I'd need, but it would make sense.

I hope I explained my question clearly and look forward to any advice you can throw at me.

Many thanks!

---

<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:** [June 22, 2019, 5:54am UTC](https://discuss.elastic.co/t/advice-on-design-query/182743/2 "2019-06-22T05:54:28Z")

</div>

Closed on June 22, 2019, 5:54am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
