Instantsearch.js: Adding parameter manually

Created on 22 Dec 2015  路  12Comments  路  Source: algolia/instantsearch.js

Can any one please tell me how can i add parameter into the query string before start();

Needs Investigation

Most helpful comment

I figured it out in-case someone has the same problem:

searchParameters: {
         facets: ['status'],
         facetsRefinements: {status: ['published']}
    }
}

All 12 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthonyBertrant picture anthonyBertrant  路  3Comments

proudlygeek picture proudlygeek  路  4Comments

vvo picture vvo  路  4Comments

ChristopherDosin picture ChristopherDosin  路  4Comments

francoischalifour picture francoischalifour  路  3Comments