# Only show one hit per defined group of documents

**URL:** https://discuss.elastic.co/t/only-show-one-hit-per-defined-group-of-documents/134056
**Category:** Elasticsearch
**Created:** [May 31, 2018, 1:01pm UTC](https://discuss.elastic.co/t/only-show-one-hit-per-defined-group-of-documents/134056 "2018-05-31T13:01:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![randel\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/randel_2/32/31785_2.png) [@randel\_2](https://discuss.elastic.co/u/randel_2)
#### Post date: [May 31, 2018, 1:01pm UTC](https://discuss.elastic.co/t/only-show-one-hit-per-defined-group-of-documents/134056/1 "2018-05-31T13:01:31Z")

</div>

I'm indexing books with authors/titles and would like to know if there is a better structure then I have so far. One book can have many different titles (different editions/languages) and when searching for a title only the best matching title (depending on the language of the user) of a matching book should appear in the results. So that each result is a different book.

I was looking at parent/child but it didn't seem to fit my usecase. If I include the editions as nested documents into each book, the sort script can't access the nested editions (via inner hits) which seems to prevent picking the best matching language/title of the book.

So right now my best guess is a two step search - one for the right books ([https://stackoverflow.com/questions/15577474/combined-non-nested-and-nested-query-in-elasticsearch/22253348#22253348](https://stackoverflow.com/questions/15577474/combined-non-nested-and-nested-query-in-elasticsearch/22253348#22253348)) and in a second step with a second index I determine the best matching edition by using a filter with the bookid from step 1. But that means I can't use autocomplete... Is there a better way?

---

<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 28, 2018, 1:01pm UTC](https://discuss.elastic.co/t/only-show-one-hit-per-defined-group-of-documents/134056/2 "2018-06-28T13:01:31Z")

</div>

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