This is a problem related to a typical e-commerce requirement.
I am using ElasticSearch for all the below use cases.
I am confused about whether or not to use MongoDB for the sorting part.
I have the data in the following format:
Product JSON:
{
"name": "String",
"description": "String",
"characteristics": [
{
"name": "Brand",
"value": "Apple"
},
{
"name": "Color",
"value": "Red"
},
{
"name": "Storage",
"value": "64GB"
},
{
"name": "stockStatus",
"value": "IN_STOCK"
}
],
"prices": [
{
"priceAmount": 100000,
"discounts": [
{
"discountAmount": 300,
"conditions": [
{
"name": "primeCustomer",
"value": "true"
},
{
"name": "oldCustomer",
"value": "true"
}
]
},
{
"discountAmount": 500,
"conditions": [
{
"name": "deviceType",
"value": "premium"
}
]
}
]
}
]
}
I want to
- Search based on name or description.
- Filter based on characteristic name and value.
- Sort based on the discounted price.
- Pagination
- Filter products lying at a particular price(discounted) range.
Multiple discounts can be applicable at the same time – like in the above example, the customer is prime+old as well the device is premium. I want to evaluate the conditions on runtime based on the input parameters and then sort the results based on the final discounted price.
I will definitely run benchmarks for both ES and MongoDB but before that, I would like to know are there any recommendations for this type of scenario?
I have to operate on millions of product documents.
Right now, I precompute all the possible combinations of the conditions and then create a single price document for each combination to avoid any calculations on the runtime. But the combinations are too much given the conditions are increasing every day with new business requirements.
5