Louis Lebrault
Louis Lebrault

Reputation: 96

Algolia vue-instantsearch : disjunction between two distincts facets

Using algolia vue-instantsearch, i’m encountering a special case and i’m having an hard time finding a solution.

Refinement behaviors is that you get the results that matches all your refinement filters.

If i filter on a brand and a price, i’ll get the results that matches both the brand and the price.

I need to add some specific filters that work differently. I would like to be able to say “returns me the results that matches either refinementA, or refinementB, or refinementC.”

The reason is that those refinements are checking fields that are not present on all the products.

If i check a value for refinementA, i want to keep all the results that has no value for field corresponding to refinementA, but remove those that has a value for refinementA that does not match with the one i filtered one.

Im thinking about handling myself some inputs instead of ias-components, and modifying by hand each query that is send to algolia by checking the value of my own inputs when searchFunction is triggered (https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-searchfunction).

I did not found yet how i can trigger a search from an non-vue-instantsearch input event, and i’m not sure how the above solution could affect the internal working of vue-instantsearch.

I’m looking for feedbacks about a more standard way of doing this, or for any advices !

Upvotes: 1

Views: 500

Answers (1)

Louis Lebrault
Louis Lebrault

Reputation: 96

I got the answer by exchanging with a vue-instantsearch maintainer.

vue-instantsearch does not provide any option to do it.

A workaround is to overwrite algoliasearch search method, that is used under the hood by vue-instant-search.

const client = algoliasearch('', '');
const originalSearch = client.search;
client.search = function search(queries) { ... }

More informations in this github issue : https://github.com/algolia/vue-instantsearch/issues/1102

Upvotes: 1

Related Questions