Vendure: Search with many facetValueIds of the same facet in Shop GQL

Created on 1 Jun 2020  Â·  2Comments  Â·  Source: vendure-ecommerce/vendure

Is your feature request related to a problem? Please describe

I would like to search in Shop GQL with many facetValueIds of the same facet. For example:
(These prints are from my shop)

  1. Here we have all products
    Anotação 2020-06-01 093209

  2. Here just "Apple" products
    Anotação 2020-06-01 093229

  3. Here just "Samsung" products
    Anotação 2020-06-01 093301

  4. And here should show both "Apple" and "Samsung" products
    Anotação 2020-06-01 093245

Here the query behind the last print:

query SearchProducts {
  search(input: {
    take: 5
    collectionId: "2"
    groupByProduct: true
    facetValueIds: [ "5", "3"]
  }) {
    totalItems
    items {
      productId
      productName
      facetValueIds
    }
  }
}

Describe the solution you'd like

I think the way it is working now is not right in any situation. Maybe a solution its change the default search strategy. I'm not a Vendure expert (yet😜) but i think maybe its related to this line of code where have a loop of facetValues AND in MySQL.

https://github.com/vendure-ecommerce/vendure/blob/1915538691bfdafd94a2e6ce3b5e6175d2e09be1/packages/core/src/plugin/default-search-plugin/search-strategy/mysql-search-strategy.ts#L130

Another approach its to configure in these settings in query search input as an option. But i don't think that its not necessary because i don't think that someone will search with operator AND.

@vendurcore feature ✨ @vendurelasticsearch-plugin

Most helpful comment

Yes, I had faced the same issue yesterday, I have been meaning to comment on this feature as well. Seems like the approach jonyw4 mentioned is the common eCommerce search strategy. would love to see this feature come true.

All 2 comments

Yes, I had faced the same issue yesterday, I have been meaning to comment on this feature as well. Seems like the approach jonyw4 mentioned is the common eCommerce search strategy. would love to see this feature come true.

The solution I opted for is to add a new field facetValueOperator to the SearchInput, which allows you to specify "AND" or "OR", and defaults to "OR".

Will be available in the next release!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rcorzogutierrez picture rcorzogutierrez  Â·  6Comments

michaelbromley picture michaelbromley  Â·  4Comments

mattgills picture mattgills  Â·  4Comments

drewniakradoslaw picture drewniakradoslaw  Â·  5Comments

jonyw4 picture jonyw4  Â·  6Comments