vendure-ecommerce / vendure-plus-issues

Report issues on Vendure Plus plugins here
0 stars 1 forks source link

AdvancedSearch Schema not ideal for product grouping #2

Open elauser opened 1 year ago

elauser commented 1 year ago

The Vendure search implementation is made with a variant based approach in mind. I made a webshop using the AdvancedSearch where the requirements were set on a variant based search and it worked great! Fully typed searchInput and response thanks to GraphQl codegen.

We have customers where we want the results and counts grouped by product, and the schema should return a list of products not the first variant of each product. They often have products with more than 100 variants and to not just show 10 pages filled with variants of the same product having it grouped by product is necessary. Since they also want to show the price of the variant they have a variant selector on each product card. https://webshop.stocker.alpin11.dev/category/polyline-pp

The current workaround discussed with @michaelbromley where we add all the variants on each indexed variant as a JSON serialized string would require extra filtering in the frontend afterwards to remove all the variants which don't pass the facet filter.

Also the collection count doesn't match with the typesense count somehow.

image

I think to do that we could create a second endpoint returning a different schema instead of just setting the groupByProduct flag and returning one variant per product and hackily adding extra values.

Typesense supports grouping, and we implemented it by grouping by product_id and setting the maximum group_limit https://typesense.org/docs/0.23.1/api/search.html#grouping-parameters

We could take over development for that feature if the AdvancedSearch Plugin source gets made available to us and you think that this is a valid way to extend the Search.