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) 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?