Hi @cindy.cullen,
thank you for your response. Basically, all you send matches with the information I found before which is great. However, it still feels to me that counting is incorrect.
I had two ways how users can search on Algolia.
- Suggesting similar videos as one user found. Code below:
async findSimilar(): Promise<Video[]> {
const client = algoliasearch("TOKEN", "TOKEN");
const index = client.initIndex("MY_INDEX_COMES_HERE");
const models = 'BMW X6';
const channelName= 'My Channel';
const optionalWords = models + ' ' + channelName;
const params = {
'optionalWords': optionalWords,
filters: `publishedAtStamp != SOME_DATE_COMES_HERE`,
hitsPerPage: 20
};
console.log('Searching similar videos on Algolia!');
const response = await index.search(models, params);
return response.hits
}
- When user search for some video, this is executed on server and only after user press submit, so once not for every key stroke
async findAllIndexed(searchTerm: string, page: number = 0): Promise<any[]> {
const client = algoliasearch("TOKEN", "TOKEN");
const index = client.initIndex("MY_INDEX_COMES_HERE");
const response = await index.search(searchTerm, {page});
console.log('Searching indexed videos on Algolia');
return response.hits;
}
As I mentioned in the original post, I was thinking that my methods are called multiple times and it’s problem on my site so I added console.log to code just to verify how many times each method is being called. I found out that console.log is fired once and after 5 min of waiting (until analysis refresh) I see e.g. 12 queries in the analysis.
Maybe I just don’t see the issue on my site but the code seems to be legit and debugging suggests it’s working fine as well.