Hi <@U01NZ4D0LDD> with whom in your team i can dis...
# community-help
i
Hi @Jason Bosco with whom in your team i can discuss case for angular instant search? I am using angular instantsearch with typesenseInstantAdapter for algolia, i build custom autocomplete component via angular material. I want to provide such behavior: search should be triggered only when i start typing letters in inputbox of autocomplete and not on initial page loading
j
@Ivan Volkov I've done something similar with Vue and vanilla instantsearch.js. I'm personally not too familiar with Angular, but may be @Kenneth Koniouchine can help?
In Vue what I had to do was add a conditional rendering statement to the
Hits
component to only show it if the query in the search box is not empty
i
@Jason Bosco thanks for answer, but we want to optimize page loading, thats why i want initial search results be empty or search not triggered at all, i want trigger search only after typing in searchbox. @Kenneth Koniouchine can i do something like this with angular instant search?
j
I think the link I shared above prevents the initial search query on page load, no?
i
Yes, that is what i was looking for,thank you very much!🙌
👍 1
j
The one thing to keep in mind in that code snippet: instead of
algoliaClient.search(requests)
you want to call
typesenseInstantSearchAdapter.search(requests)
in the last line
So it would look something like this:
Copy code
js
const searchClient = {
  ...typesenseInstantSearchAdapter,
  search(requests) {
    if (requests.every(({ params }) => !params.query)) {
      // Here we have to do something else
    }

    return typesenseInstantSearchAdapter.search(requests);
  },
};
🙌 1
i
Yeah, again thanks a lot!
k
Looks like Jason beat me to it. Feel free to PM me if anything else comes up 👍 In terms of the initial page load, it's also worth noting that the instantsearch library displays the initial hits to initialize the connection for faster subsequent searches. I'm not sure if this also happens with Typesense, but if it is, it's worth considering. In my own work I tend to prevent the initial page load by conditionally rendering only the refined results with an *ngIf to avoid any jarring UI experiences. While this does still send that initial request, it's not a big deal like with Algolia where you're counting every single request.
i
Thank you for your answer and advice🙌