InstantSearch.js custom widget increase returned results

648 Views Asked by At

As you can see in the code bellow, I made 2 custom widgets, one for searching one for displaying results, but I cannot increase the limit of the returned results. When the page loads, it automatically makes a request and retrieves the default results with no query.

We have more than 500+ results which all have to be displayed on the UI, and I cannot modify the limit of the results anywhere. The limit is always 200. As a backend, I am not using algolia but rather meilisearch, but I do not this impacts this in any way.

As you can see in the images, the searchParamters are modified and set to limit 1000, but when the request is made, it sends it as 200.

enter image description here

enter image description here

       const search = instantsearch({
            indexName: "store",
            searchClient: instantMeiliSearch(m_host, m_key),
        });

       search.addWidgets([
        configure({
            hitsPerPage: 1000,
            limit: 1000,
            filters: `image!=null AND is_active=1 AND (countries_ids=${country_id} OR countries_ids=0) AND goto_link != null`,
            attributesToHighlight: [],
            paginationLimitedTo: 1000,
        }),
        {
            init: function (opts) {
                const helper = opts.helper;

                const input = document.querySelector('#searchbox');
                input.addEventListener('input', function (e) {
                    helper.setQuery(e.currentTarget.value) // update the parameters
                        .search(); // launch the query
                });
            }
        },
        {
            render: function (opts) {
                let results = opts.results;
                // read the hits from the results and transform them into HTML.
                let res = toArray(groupBy(filter_stores(results.hits), 'category_id'));
                $(`.stores-list`).empty()
                $(`.categories-list`).hide()
                res = res.map(it => {
                    let copy = it;
                    copy[1] = _.orderBy(it[1].map(store => {
                        store.default_rank = store.hasOwnProperty(`rank_country_${country_id}`) ? store[`rank_country_${country_id}`] : store.default_rank;
                        return store;
                    }), 'default_rank', 'asc');
                    return copy;
                });
                res.map(pairs => {
                    let [category_id, stores] = pairs;
                    $(`#category_${category_id}`).show()
                    let html = stores.map(h => create_store(h)).join('')
                    $(`#store_list_${category_id}`).html(html)
                });
            },
        }
    ]);

    search.start();
0

There are 0 best solutions below