Optimise algolia search query

I am using Algolia search on my website with instantsearch js api.
I am struggling with optimising algolia search queries.

As I have limited operations Hit count for a month. I saw on each page load making 2 hit.
Instead I want to use hit only when user click on the search Textbox.

I tried to put my entire algolia search initialisation code on textbox click function but it is not working.

can anyone have any idea how to optimise algolia queries.

Hi there, to do so you can use:

Hi,

No searchAsYouType param cant help me here.

My issue is when i hit the below query it fire two operations in Algolia. I am loading this code on document ready.

    var search = instantsearch({
        appId: 'T2B04QR9B0',
        apiKey: '28985d34dee832a8f54db2e290beaec7',
        indexName: 'wp_posts_wellgorithms', // test_wellgorithms
        searchParameters: {
            facetsExcludes: {"vp_weight": [excludeWeight]},
            disjunctiveFacetsRefinements: {
                'taxonomies.category': ["Light"]
            },
            facets: ['taxonomies.category']
        }
    });
    search.start();

I want it should only get fire when search Textbox is focused, changed or clicked.
How can I optimise this query?
can you please help me with it.

Okay got it, to do so you need to use this trick:

The goal is to either use a different API client or just to use the searchFunction hook https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-searchfunction

So you can avoid the first query when the page loads

Hi @vvo, thanks it works and stops the search query if search param is empty.

but I want if someone click on the search textbox the default query should get fire with all data.
so can say without handling that It will not meaningful for me.