Ais-input and get parameter

Is there any way I can import the value of a GET parameter to the ais-input on page load?

I want when the user enters the link /search?q=macbook to fill the input and search.

for the record, after checking the documentation it seems that this can be done easily by adding the query to the search store using something like

            this.searchStore.query = getparameter;
1 Like

Yep, that’s how you can do it, an option that doesn’t require you to edit the searchStore is by adding the query prop with the value you get from the url to <ais-index>


Hey @haroen, thanks for the link.

In the context of this question, is there any way to specify multiple values for a query prop? Possibly an array of values.

My code looks like this

<product-list :category_id="{{ $category->id }}">

and i’d like to show products from multiple categories (basically a category’s subcategories’ products)

I tried passing an array and multiple times the category_id without luck.

Any ideas?

Hey @chrys,

Sorry for answering late. I’m not 100% sure what you mean though, where does <product-list> come from? Can you share some code with input that works and something that you want to work?


Hi @haroen,
Product-list is basically a wrapper for ais-index.

    <ais-index :search-store="searchStore">

    import {
    } from 'vue-instantsearch';

    const store = createFromAlgoliaCredentials(
    store.indexName = 'products';

    export default {
        props: ['category_id'],
        data() {
            return {searchStore: store}
        created() {
            this.searchStore.addFacet('category_id', FACET_OR);
            this.searchStore.addFacetRefinement('category_id', this.category_id);


I basically want to give two values in the Facet Refinement. If I give 1 and 2, I expected both category products to be returned.

Hi @chrys

If you want to have products that are in two categories at the same time then you should probably use a FACET_AND. FACET_OR is for retrieving facets from either categories. To set two values you should call addFacetRefinement twice with one value at a time.

Let us know how that works for you.


It worked thank you @Bobylito !