Ecommerce product list, filter and search in Mongodb and elasticsearch

Viewed 446

I am working in ecommerce app, developed in spring boot. I have product catalog stored in mongodb currently. There is parent-child relationship for product variants.. i.e. variant array inside main product.. so my mongodb structure is like:

{
    name,
    id,
    category,
    subcategory,
    rating,
    gender,
    brand
    .
    .
    .
    variants:[
        {
            size,
            price,
            color,
            quantity,
            mrp,
            discount,
            offers[{id,title,subtitle},....]
            store_id,
            filters:[{name:"",value:""},{name:"",value:""}]

        },{
        }

    ]
},
{
}

So here I am showing products in list based on brand,category,subcategory (parent level) and then filter with variants' data like size,color,price range, discount percent etc...

My listing and filter with sorting(price low to high, newest etc) is working properly with this structure. Filter is totally dynamic where key value pair is stored as filter array for each variants. I am showing filter in the application with all applicable fields like gender,discount,category,brand,filter values.

Now I want to use elastic search for searching. I have used mongodb full text search, but autocomplete,spell mistake etc is not feasible in mongodb. so I have to use elastic search. Now my question is how can I use same structure in elastic search with parent/child model? In elastic, its difficult to use nested array unlike mongo. Also to use filter/sorting along with search text in elaticsearch with dynamic filter criteria seems not same as mongodb aggregate/match etc..

How to use both mongodb and elastic search efficiently for filter,search to overcome this issue?

0 Answers
Related