Indexing m:n relations

Hi,

I would like to index documents of type A and B that have an m:n relation
between them (indexing 1:n is pretty straightforward using parent/child
relationships or nested documents).
For example, I would like to find all documents of type A that have a
related document B which itself has a property x = 123. Currently I nest B
within A, but every time a specific B object is referenced by an A object,
it gets stored in the index again as a seperate document (plus all
documents that B references itself). Since the data model contains many
relations, the index gets very large and building queries spanning the
nested structures is rather complex and error-prone.
I really would like to index A and B as separate documents which contain a
reference to each other. But this makes something like a filtered query
across different document types necessary.
Something like "Search for all Bs that have x = 123 and use the results as
a filter on A". I could do that within my application, but I would need to
retrieve ALL hits for the first query on B (since the results need to be
sorted on some property of A) and use the results to build a filter for the
second query on A. Two queries and probably lots of data exchanged between
my application and Elasticsearch.
Is there a simpler solution for this?

Regards,
Pat

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0d9877f0-ed40-4606-ba37-85b2998ee907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.