-2

I have products and their brands, Earlier my mapping was

{
"product_id",
"product_name",
"brand_id",
"brand_name",
"city_id",
//other filters associated with product
}

It was working fine until i needed to search on brands too, with the current mapping it was hard to paginate the document, so i started to store brands separately, now the schema was same but with a new column doc_type

{
"product_id",
"product_name",
"brand_id",
"brand_name",
"city_id",
//other filters associated with product
//doc_type . product or brand
}

But i cannot search for a brand with filter associated to product, for ex find brand with products in city A, i can use application level joins but suppose if i got 100k products with current filter i need to store those ids in memory before i query on brand. I can add those filters in brand mapping but it is not only wrong, it will be very hard to keep track of updates and deletion of products in brand. Being a newbie in nosql my design seems absolutely wrong.

How can i design it better so to enable search and pagination on both products and brands with filters associated to products? I can use the first version, seems like elastic added support for pagination with aggregation but it seems like a workaround not a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.