Replies: 10 comments
-
Hope I'm not off-topic, but couldn't we accept an array of facets and consider these facets should be OR'd? |
Beta Was this translation helpful? Give feedback.
-
addFacetRefinement({
attributeName: 'categories',
value: 'tv'
type: 'or'
}); this would a bit map what we propose in instantsearch.js If I am also off-topic let me know :) |
Beta Was this translation helpful? Give feedback.
-
hmm but what would it be OR'd with? The previous facet values? The next that will be added? Both? |
Beta Was this translation helpful? Give feedback.
-
Oh yes ahah tricky, type (or, and) of refinement is bound to context (other refinements in same facet). So basically you would have to provide them all at once or default to and |
Beta Was this translation helpful? Give feedback.
-
Any updates on this issue? |
Beta Was this translation helpful? Give feedback.
-
Maybe the solution is to introduce a new abstraction to build such queries, much like what is done in ruby gems for SQL clients for instance. A predicate object represents a boolean expression and can be combined with another predicate using or/and methods that return a new compound predicate for the new boolean expression. // Returns a predicate object
let filter1 = algolia.filter('a = foo');
// Builds a compound predicate from the previous filter predicate
let filter2 = filter1.or('b = bar');
// Another compound from the previous compound predicate
let filter3 = filter2.and('c = baz');
filter1.toString(); // 'a = foo'
filter2.toString(); // 'a=foo OR b=bar'
filter3.toString(); // '(a=foo OR b=bar) AND c=baz' Of course, one would rather write something like this: search.setFilter(algolia.filter('a = foo').or('b = bar').and('c = baz')) What do you think? |
Beta Was this translation helpful? Give feedback.
-
In my idea, this would set the unified filter parameter and not mess with the facet/tagFilters. |
Beta Was this translation helpful? Give feedback.
-
I like the concept of creating / managing with objects. It should make it possible to do complex refinements. I'm wondering how one can remove a predicate / filter?
Does that mean you need to specify That's a good start, let's iterate! (cc @pixelastic @vvo) |
Beta Was this translation helpful? Give feedback.
-
@bobylito I'm not sure I get your question. As for removing predicates, it has to be thought carefully.
You might want to remove the "basic" predicates like So to sum this up, whenever we remove a predicate, the action is to replace its parent predicate by the other predicate of the expression. If it has no parent, just delete the predicate. The question that remains to me is: how do we address/identify those predicates? I think that covers everything? |
Beta Was this translation helpful? Give feedback.
-
How to be able to handle 'or' filtering like
a=foo or b=bar
.We could could let the user to set facetFilters like for the numeric refinement and the tags. The only problem, is then we avoid conflicts by not letting the user use methods such as add or remove until they clear the filters.
Opinions? @algolia/javascript
Beta Was this translation helpful? Give feedback.
All reactions