lundi 15 novembre 2021

Designing a reranking service/system following some hard-bound rules

Description: Given a initial Ranked list of products. Design a reranking system that reorders the items in the list based on the rules defined.

E.g. I/p format: query: "aata": ["Aashirvad multi-grain aata", "Aashirvad 100% wheat atta", "aata maker", "aata sieve", etc]

            [{
                name: ,
                brand: , 
                category: ,
                description: ,
                sales_data: {
                            MRP_type: ,
                            mrp_price: , 
                            sell_price: 
                            }
                meta_info: {
                                type: ,
                                color: ,
                                size: ,
                                gender: unisex/male/female ,
                                shelf_life: [for grocery ]
                            }
                relevance_score: ,

                }, 
            {
                name: ,
                brand: , 
                category: ,
                description: ,
                sales_data: {
                            MRP_type: ,
                            mrp_price: , 
                            sell_price: 
                            }
                meta_info: {
                                type: ,
                                color: ,
                                size: ,
                                gender: unisex/male/female ,
                                shelf_life: [for grocery ]
                            }
                relevance_score: ,

                },
            ]

Example Rules:

  1. No 5 consecutive products can be of same category.
  2. No 3 consecutive products can be of same brand
  3. No 4 consecutive products can be of same color
  4. No 4 consective products should be in similar price range, where range is defined as +/- 5%

The system need not to be dynamic. Flow for any rules can be assumed to created/defined manually. Additionally, there can be relation between multiple rules.

Note: We can assume that rules are defined in such way that there is no collision in condition of any two rules.

Design A Low level design for the reordering system.

Any recommendation/suggestion on any design pattern or any existing framework that can be used. p.s. I tried using drools rule engine. But I was struggling in defining the flow/algorithm and exit condition.

Aucun commentaire:

Enregistrer un commentaire