Let's say I have 2 tables in my relational DB, one called customers, which
contains customer data and one called metrics, which contains customer
metrics against customer id and date. For most of my queries, I will need to
join the two tables on the customer id. How can this behavior be emulated
efficiently in es?
My SQL queries are usually like
"SELECT customers.customerid, SUM(metrics.logins), SUM(something else), ...
FROM metrics JOIN customers ON metrics.customerid=customers.customerid
WHERE metrics.date BETWEEN date1 AND date2
GROUP BY customers.customerid
ORDER BY SUM(metrics.logins) DESC"
We could do this in the client side, but that would be very inefficient,
right? Can I use the _parent mapping and has_child query to do this? Does it
return both the relevant parent and child docs as a single merged document?
I could store both of them together in a de-normalized way, but that looks
ugly. Any other ideas?