Query for documents presented in different index or type too

Is it possible to fetch a subset of documents of IndexA so that the documents are presented in IndexB too? "Presented in indexB too" means that document.fieldA value of indexA is the same as document.fieldA value of indexB. Or even better, if I can compare by several fields values.

For example,
if IndexA contains 2 documents: [{"name":"John", "isManager": true},{"name":"Tim","isManager":false}]
and IndexB contains 1 document:[{"name":"John", "isManager": false}]
I want to be able to search over IndexA and get only "John" document because it also presented in IndexB. Even more, if possible, I'd prefer to get nothing because even John is not exactly the same - it is not marked as "isManager" in indexB.

I'm pretty sure it is not possible to do what I want but asking to be completely sure.
Also is it possible to do this across types in the same index instead of across indices - so that IndexA and IndexB become typeA and typeB?

Thanks in advance for answering.

Have a look at parent/child and nested documents. There aren't other
join-like features. Usually the recommendation is to denormalize the data.

Thank you for response, Nik.

I want to explain it better - actually I have 2 indices that store similar data coming from 2 absolutely independent sources. Data may come in different time and may not come from one of the sources at all (or come partially). So I have 2 independent, denormalized and self-containing data sets and I need a union between them. There is nothing to denormalize. Building a nested mapping or something like this seems to be not so good approach in my case.

It looks like I cannot do this in a single ES query and need to do this in the code. Just wanted to be sure before I start coding this.

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