-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple groups of filters for search products query #726
Comments
We discussed this on Slack. Here is my piece of code that can be used to extend ListQueryBuilder object (Product or ProductVariant) that does similiar to what you ask for, though without customizable logical operator - it will always look between facetValues of same facet ( qb.andWhere( |
+1 for this. It does seem to make sense to be able to use the OR operator within what I've been calling 'facet value groups', but the AND operator between said groups (although I would say it makes sense, because it's what I'm trying to do with my site 😜 ). To try and give a real-world example, using place of origin of coffee beans (number in brackets shows products found by search): FILTERS - NOWT SELECTED
Country
I'd expect that when a user selects Africa, the facet counts drop to 0 for Colombia and Brazil, thus reflecting the AND condition across groups, but not on South America, as these should still be selectable via the OR condition (also obviously only one product is visible): FILTERS - AFRICA SELECTED
Country
If the user then selects South America as well as Africa, I'd expect the facet counts to jump back up on Colombia and Brazil, and the products from South America reappear, due to the OR: FILTERS - AFRICA AND SOUTH AMERICA SELECTED
Country
If the user THEN selects Colombia, I'd expect the facet count on Africa to go to 0 and South America to 1 (maybe slightly weird as they're already selected but this is the nature of facets I guess) along with the other countries, due to the AND across groups: FILTERS - AFRICA AND SOUTH AMERICA SELECTED
Country
|
Discussed this issue with Michael in Slack, so the plan is:
Michael will add later more detailed suggestion of point 2. |
Here's a suggestion of how we can support this (and many other cases) using the Elasticsearch plugin: we allow the developer to define arbitrary ES queries in the plugin config, which can implement any kind of filtering (and other) logic they need. This would enable the developer to fully leverage the power of ES without us needing to explicitly build-in support for every use-case. Rough plan of implementation:
This allows the developer to make use of the existing indexing functionality of the ES plugin, without being constrained by the default APIs exposed. AlternativeThe alternative is to implement the filter groups as a completely custom plugin. However, this means the developer need to the re-implement all the indexing logic which is not a trivial task. |
Open the continuation of this issue #815 |
Is your feature request related to a problem? Please describe.
Allow user to filter by multiple filters. For example, user want to filter some category by color (red (facet_id=1) or white (facet_id=2)) and by material (leather (facet_id=10)).
Now search query allow to input list of facets and logical operator for list https://www.vendure.io/docs/graphql-api/shop/input-types/#searchinput
Describe the solution you'd like
Allowing to pass groups of facets to search query.
For example,:
{ facets: [ { facets_ids: [1,2], logical_operator: "OR" }, { facets_ids:[10] } ], logical_operator: "AND" }
Describe alternatives you've considered
So, the only way to filter by multiple filters is querying shop-api two times.
Additional context
Probably it can be implemented by ElasticSearch plugin?
The text was updated successfully, but these errors were encountered: