question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple groups of filters for search products query

See original GitHub issue

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.

  • first time with facet_ids = [1,2] and logical operator= Or
  • second time with facet_ids=[10]
  • merge results at client side

Additional context Probably it can be implemented by ElasticSearch plugin?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chladogcommented, Feb 24, 2021

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 (OR between facetValues of x facet AND OR between facetValues of y facet AND so on…)

qb.andWhere( "product"."id" IN ( WITH targets AS (SELECT * FROM facet_value WHERE id IN (:...argProductFacetValues)) SELECT "productId" FROM product_facet_values_facet_value AS map INNER JOIN targets AS tgt ON tgt.id = map."facetValueId" GROUP BY map."productId" HAVING COUNT(DISTINCT tgt."facetId") = (SELECT COUNT(DISTINCT "facetId") FROM targets) ) , { argProductFacetValues: options.facetValueIds });

0reactions
Izaydacommented, Apr 8, 2021

Open the continuation of this issue #815

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I filter products by multiple categories with ...
Knowing that supplying an array of category IDs in my Product query will find products in any of the specified categories, and hoping...
Read more >
Filtering Groups with HAVING - Peachpit
The HAVING clause filters rows from the grouped result. To filter groups: Following the GROUP BY clause, type: HAVING search_condition.
Read more >
2 Ways to Filter for List of Items in Excel + Video Tutorial
Learn 2 ways to filter for a list of multiple items in Excel. This includes finding partial matches that contain the filter criteria....
Read more >
Video: Advanced filter details - Microsoft Support
Training: You can use the Advanced Filter to create more powerful filters, such as filtering for unique records and using operators such as...
Read more >
Quick start: Filter data by using an AutoFilter - Microsoft Support
You can filter on one or more columns of data. With filtering, you can control not only what you want to see, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found