Can any one please tell me how can i add parameter into the query string before start();
If you want to add parameters to the query string, you can use plain js :
window.location.search = 'my=parameters'
All the parameters that are not from instantsearch will be preserved with the changes of the search parameters.
Let me know if this was your issue?
sorry for my incomplete question. I was talking about adding any refinement manually without widgets.
Hello @prspace,
You can pass them when instantiating instantsearch, using the searchParameters options
var search = instantsearch({
[...],
searchParameters: {
hitsPerPage: 5,
// Any other Algolia options
}
});
@prspace did that fix your issue?
Thank you, no it didn't fix my issue as i want always to attach a filter like i have an index name listings i want to return only listings where listing.status = 'ACTIVE'.
Can you try doing something like this:
var search = instantsearch({
// other options
searchParameters: {
facets: ['listing.status'],
facetsRefinements: {'listing.status': 'ACTIVE'}
}
});
Where "listing.status" is an attribute in your records and is defined as an "Attribute for faceting" in the dashboard.
Let us know how it goes.
@prspace I updated my comment
It's worked, thank you very much.
AWESOME
I was needing the same thing but it didn't work for me, not sure why. I did add my Attribute to the dashboard still with no luck.
var search = instantsearch({
indexName: 'jobs',
searchParameters: {
facets: ['status'],
facetsRefinements: {'status': 'published'}
}
});
I figured it out in-case someone has the same problem:
searchParameters: {
facets: ['status'],
facetsRefinements: {status: ['published']}
}
}
Thanks @roszelj for the hints
Most helpful comment
I figured it out in-case someone has the same problem: