I have two different types in my index, representing the same entity but containing different body. Documents share the same ID.
Type event
is similar to { "_id": "event1", "title": "Ville's Event", "date": "2017-04-30" }
Type event_interaction_stats
is similar to { "_id": "event1", "likes_count": 10, "shares_count": 6}
The documents are splitted for performance purposes and obviously the above document examples are simplified.
Now I should be able to query all events that happen today and have more than 10 likes. I do currently first query event_interaction_stats
, fetch list of ids and then do another query to event
and in addition to date range, pass also list of id's that are allowed. This requires apparently two roundtrips to the server and the list of event ids from the first query can be large. Therefore I would prefer some other approach where both queries would be executed inside ElasticSearch and only final results would be returned to the application.
How could I accomplish this kind of behavior, or can I?