#community-help

Ecommerce Search Engine with User-added Products

TLDR Max seeks advice on handling a boolean field showing if a product is already in a user's cart for an ecommerce search engine. Kishore Nallan suggests waiting for the future "join" feature to allow merging separate indexes at query time.

Powered by Struct AI
white_check_mark2
heart1
Mar 31, 2023 (6 months ago)
Max
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Max
09:51 AM
Hi team, I have an ecommerce usecase, a classic ecommerce search engine I would say. So I have an index with all information for a product (title, description, image, price, stock, etc.). However, we have an additional feature where an user can see if he already has added a product from his search results into his shopping cart. This feature can be done on our front easily just by having a boolean "already_added" within the document fields. The problem is that we would need to have this boolean for each user (+30k users), and for each product (1M products). Eventhough putting everything into a single index would not affect performances, it would be a complicated mess to handle. I was thinking to have a global product index on one side, and on the other side, one "user personalized" index containing all products added for each user. Each time a user adds a product to his shopping cart, we update the user personalized index.
I would then, somehow (😇), do a multi index query or multi query to check if, for the current user, the products in his search results have already been added to shopping cart by adding a boolean. Is this possible ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:03 AM
👋 What you are describing is a need for a "join" feature. This way you can keep the user preference and product attributes as separate collections and then just join them at query time.

Good new: we're acutely aware of this need and have kicked off work to implement this feature. However, it's going to take some time before I can share a build for you to test it, given the scope and depth of the changes involved.
white_check_mark1
10:04
Kishore Nallan
10:04 AM
"going to take some time" == "month or two from now"
heart1
Max
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Max
10:10 AM
Hi Kishore Nallan, well a few months is good news ! Happy to know this feature is in your backlog. In the meanwhile, I think I can just have the "classic ecommerce" index on one side, and on the other side a "user personnalized" index where a user_id has a list of product_id.
With a multi search query I can have the ecommerce products and a list of products already added for a specific user. I will be able to add a display to a product if this product within the query results has already been added. But do you confirm that I cannot exclude products already added (query1) from global product results (query 2) ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:12 AM
Only if you can do 2 queries, first to fetch the IDs and then to exclude via another query.
Max
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Max
10:14 AM
Ok I am trying this

Once the JOIN feature is live on the engine, we will be able to do it with only one query ? My use case here is like a SQL LEFT OUTER JOIN
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:17 AM
Yes, you will query on product collection and then pull necessary fields from the "user_features" collection by joining on the product_id field which will be common to both collection.
white_check_mark1
Max
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Max
10:38 AM
To avoid having to change structure when the JOIN feature is live, are you able to validate my current one ?

Screen 1 is a product document from product index
Screen 2 is a user document from user_feature index

With this structure, will I be able to exclude all product ids (added_products in user document) from query results in the product index ? All the added product ids from a user document IS EQUAL to a product index document id
Image 1 for To avoid having to change structure when the JOIN feature is live, are you able to validate my current one ?<br><br>Screen 1 is a product document from product index<br>Screen 2 is a user document from user_feature index<br><br>With this structure, will I be able to exclude all product ids (added_products in user document) from query results in the product index ? All the added product ids from a user document IS EQUAL to a product index document idImage 2 for To avoid having to change structure when the JOIN feature is live, are you able to validate my current one ?<br><br>Screen 1 is a product document from product index<br>Screen 2 is a user document from user_feature index<br><br>With this structure, will I be able to exclude all product ids (added_products in user document) from query results in the product index ? All the added product ids from a user document IS EQUAL to a product index document id
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:42 AM
The user features collection should be just user_id, document_id