# Data modeling: querying multiple "types" off a single denormalised index

**URL:** <https://discuss.elastic.co/t/data-modeling-querying-multiple-types-off-a-single-denormalised-index/202722>\
**Category:** Elasticsearch\
**Created:** [October 8, 2019, 8:26pm UTC](https://discuss.elastic.co/t/data-modeling-querying-multiple-types-off-a-single-denormalised-index/202722 "2019-10-08T20:26:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iftheshoefritz](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@iftheshoefritz](https://discuss.elastic.co/u/iftheshoefritz)\
**Post date:** [October 8, 2019, 8:26pm UTC](https://discuss.elastic.co/t/data-modeling-querying-multiple-types-off-a-single-denormalised-index/202722/1 "2019-10-08T20:26:58Z")

</div>

(I'm using types in a relational sense, not in the old elasticsearch "multiple types in an index" sense)

I have a typical relational data model with several types in a hierarchy. For illustration sake, let's call this an online book seller tracking publishers, authors and books:

```
| publisher | 1---* | author | 1---* | book |

```

Each `publisher` has many `author` who in turn have many `book`. In reality there are more layers of the hierarchy but this will suffice.

I need to run queries against each type where the query has to handle fields for the type and its parents: for the `book` query, I need to be able to search e.g. `book.title`, `author.name` and/or `publisher.name`. For the `author` query I might need to search `publisher.name` or `author.name`.

My initial plan was to create one index per type with all the columns that I need to query:

`book` index: `book`, `author` and `publisher` columns  
`author` index: `author` and `publisher` columns.  
`publisher` index: just `publisher` columns

That feels like it will get complicated, as any time a `publisher` changes, I'd have to update `publisher`, `author` and `book` indexes.

Finally the question: Is it reasonable to maintain only one of these indexes that holds ALL the data (so I suppose just the `book` index) and then use it for queries about `author` or `publisher`, even when they have completely independent of `book`? e.g. I might query authors by location without referencing or caring about what books they wrote.

---

<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:** [November 5, 2019, 8:27pm UTC](https://discuss.elastic.co/t/data-modeling-querying-multiple-types-off-a-single-denormalised-index/202722/2 "2019-11-05T20:27:04Z")

</div>

Closed on November 5, 2019, 8:27pm UTC

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