Intersectional search from two indices

I have two indices in Elastic: Track and Messages.
Each index has ServiceId field.

Search in the Tracks index is always performed by fields (exact value) in the index.
Search in the Messages is always performed by free text search in the index.

I need to implement an intersectional search from the both indices. To find ServiceIds from Tracks index by exact fields values and then find ServiceIds from Messages index by free text search and then to intersect the results = array of ServiceIds.

The actual result to the user is the list of Tracks by these ServiceIds received from the intersect action.

How can I do it? Each search (from Tracks and Messages) should return all the documents and only then intersect should be performed but as I understand Elastic can not return all the documents (suppose I have hundred of millions documents in each index) and intersect action is not correct...

111

Still help needed...

This sounds like a join, which Elasticsearch does not support. I therefore suspect you will need to run two separate queries and merge the data in your application.

Hi Christian,
You are right - it's a join. But my problem is that the result from the first search and from the second one can get correct ServiceId but when I join (intersect) them I get zero documents result.
Is my explanation clear? If not, I'll try one more time...

You need to share the exact queries you are running and the mapping.

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