Skip to content

Instantly share code, notes, and snippets.

@seandogg
Created April 18, 2019 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seandogg/df6288edf9dd8e72c9d376ca16c00022 to your computer and use it in GitHub Desktop.
Save seandogg/df6288edf9dd8e72c9d376ca16c00022 to your computer and use it in GitHub Desktop.
search: instantsearch({
appId: algolia.config.app_id,
apiKey: algolia.config.search_api_key,
indexName: '' + algolia.config.index_prefix + 'products',
searchParameters: {
clickAnalytics: true
},
urlSync: {},
searchFunction: function (searchFunctionHelper) {
// Set query parameters here because they're not kept when someone
// presses the Back button if set in the `init` function of a custom widget
var helper = instant.search.helper;
var page = helper.getPage();
helper.setQueryParameter('highlightPreTag', '<span class="ais-highlight">');
helper.setQueryParameter('highlightPostTag', '</span>');
if (instant.distinct) {
helper.setQueryParameter('distinct', true);
}
if (!!collectionFacetConstraint && !!collectionFacetValue) {
helper.setQueryParameter('filters', 'collections:"' + collectionFacetValue + '"');
}
if (!!collectionFacetValue) {
helper.setQueryParameter('ruleContexts', [ collectionFacetValue ]);
}
helper.setPage(page);
searchFunctionHelper.search();
}
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment