Brett
Brett

Reputation: 1781

How do you addFacetRefinement with multiple values in Algolia?

I have a list of places: [A, B, C];

A user can create an item and associate a place to it:
item1 > place: A

The user can search for a place and get the items: this.algoliaService.helper.addFacetRefinement('place', A);

All this works as expected, my question is:

How can I setup the creation of the item so it is associated with all the places ?
So a user picks a "ALL places" and any place search would have this item in the results?

Is there a way to add "All Places" in Algolia? this.algoliaService.helper.addFacetRefinement('place', A,B,C);

Thanks

Upvotes: 0

Views: 462

Answers (1)

marchelbling
marchelbling

Reputation: 1939

I see 2 possibilities:

  1. in your snippet, you are listing some places; if you want to allow searching in any of the facet values, then you can do what we call "disjunctive faceting" (basically, this does an "OR" on the facet values so would return all objects that have at least one of the values in their record). We have some code snippets for js or mobile clients.
  2. in case you don't want to provide an exhaustive list of values, you'd have to add another boolean field like has_place and filter on this field

Upvotes: 1

Related Questions