I am trying to figure out, if there a way to reduce a number of
queries in my search.
I use data model like the following:
Persons and Locations are tied with Relations as many-to-many.
Relations can be of different types (e.g. "home", "work").
The documents are indexed into the same index with different types:
Person, Location, Relation.
My search should find all Persons which are related to a Location with
Location.name = "someLocation",
and Relation.type = "someType".
I can do that by running a number of queries sequentially:
- find Location.id by Location.name (termFilter, filteredQuery);
- find all matching Relation.personId by Relation.type and
Relation.locationId (andFilter, filteredQuery);
- find all matching Persons by Person.id (termFilter, filteredQuery).
Is it possible to simplify this search somehow, is there a way to do
it in one query?