I have two types in my ElasticSearch index.
Product- Stores all products information
{
"ProductId":"P1",
"Name":"Refrigerator"
}
Owner- Stores all products with owner X (CSV)
{
"OwnerId":"o-id1",
"Products":"P1,P2,P3,...,Pn"
}
Note:
One product may have multiple owners.
One Owner can handle multiple products
Now, to build a query to retrieve information about all products with a particular owner. I first query Owner type and get all the product ids then I query Product type and pass the productId's obtained, using term query. But this makes the query very slow as the number of products could be very high (100,000). Also, I want to avoid two queries.
Is there a better way I can model these two types so that the queries could be faster?