Instantsearch.js: performing a facet search

Created on 15 Mar 2016  路  5Comments  路  Source: algolia/instantsearch.js

Hi guys,

I am trying to perform a search based on a given facet that I previously set up in Algolia. Something like this:

if($("#hits").length){
InstantSearch.addWidget(
instantsearch.widgets.hits({
container: '#hits',
hitsPerPage: 10,
facetFilters: [
{"parentCategoryName:Art"}
]
templates: {
item: getTemplate('hit'),
empty: getTemplate('no-results')
}
})
);
}

I don't know if this is meant to be done in "hits" or "searchbox"
Help would be much appreciated!!! Thanks

Most helpful comment

Hi filimar, I believe what you want is to pre-select a specific filter for your search interface?

The hits widgets has no facetFilters option. You should use this:

var search = instantsearch({
  // ... other options
  searchParameters: {
    facetsRefinements: {
      parentCategoryName: ['Art']
    }
  }
});

let me know

All 5 comments

Hi filimar, I believe what you want is to pre-select a specific filter for your search interface?

The hits widgets has no facetFilters option. You should use this:

var search = instantsearch({
  // ... other options
  searchParameters: {
    facetsRefinements: {
      parentCategoryName: ['Art']
    }
  }
});

let me know

You saved my life dude!! Thanks so much!!

OSS FTW!

Is this documented somewhere?

It is hidden in the Helper documentation, but I just submitted a PR to have a mention of it in the instantsearch documentation.

https://github.com/algolia/instantsearch.js/pull/1027

I'd appreciate your feedback @joshuabaker, to tell me if this is clear enough

Was this page helpful?
0 / 5 - 0 ratings

Related issues

egyprotech picture egyprotech  路  3Comments

devwax picture devwax  路  3Comments

vvo picture vvo  路  4Comments

francoischalifour picture francoischalifour  路  3Comments

jvreeken picture jvreeken  路  3Comments