Filter search based on city paramtner

Hi
Here is my search index schema :

{
  title: 'something',
  ....
  commonFields: {
    city: 0,
    price: '100$',
    ....
  }
}

I want to filter search result based on given city number.
For example i just want to search in the city number 0.

I’m coding with react, so i’m using react-instantsearch.

How’s possible

Hi there,

First you need to add a facet on this field. You can do it with specifying commonFields.city as a facet.
You can do it by using the dashboard or an API client.

Then you can use a refinement to filter on this facet: https://community.algolia.com/react-instantsearch/widgets/RefinementList.html#description

Does that answer your question?

Best,

Thanks rcs for the quick reply

That’s right … but i need to activate one of the facet items by default
I’m getting the current city from cookie and then i should pass it to the Algolia search somehow to filter it accordingly.

Its possible ?

Oh … i just found defaultRefinement props which will do it

Thanks …

Now i just need to hide the face list