As a newcomer to the world of elastic search, I could use some guidance on querying. I'm also open to any suggestions on modifying my MongoDB Schema.
I'm interested in finding out how I can use elastic search to display available products based on specified queries and filters.
For example:
{
products: [{...}, {...}, ...],
filters: [ ... ]
}
The Schema for products is:
{
title: "...",
description: "...",
categoryId: ObjectId,
variants: [ variant1ID, variant2ID ],
... other details
}
The Schema for Variant is:
{
product : objectId,
image: ..,
price: ...,
attributes:[
"SIZE-XL",
"COLOR-BLUE",
// and more
]
}
Initially, I thought about retrieving filters based on category, assuming each category has fixed facets. However, I realized that search queries don't need to be restricted to a specific category.
I am considering storing products in elastic search in the following format:
{
productId: "...",
title:"..",
description: "...",
categoryId: "....",
image: "..",
variantId:"...",
price:"..",
attributes: [
{
name:"SIZE",
value:"XL",
},
{
name:"COLOR",
value:"BLUE",
}
// more attributes
]
}
Essentially, storing each variant separately along with its product title and description for faster and easier searching.