Total searches seems to be incorrect

Hi guys,

how is Algolia getting charged? Everywhere I see it’s a price per unit while 1 unit is 1000 searches or 1000 indexed items.

I tested with my small project with 25k items in the database and I was surprised that each of my searches is counted multiple times, actually, it looks like it multiplies the search with the number of results it found.

So for example I make one search for text ‘Test’, I make sure I’m not performing any other searches and I wait until Algolia analytics refresh and I see there 12 new searches? Why? I would expect this is a single search, not 12.

At first, I was thinking that I had some issue with my code so I tested the same with the UI Demo app and the results were basically the same.

Is this some kind of settings I’m missing or am I doing something wrong?

Hi @anduritko, we count search requests. If you have searchAsYouType enabled (this is enabled by default to keep the search responsive), each character in the query counts as a search request. If your query is ‘apple’, it will count as 5 search requests. If you are searching multiple indices with the same query, and not using the multipleQueries method, it will multiplied by the number of indices. So, if you are searching in two indices for ‘apple’, it will result in 10 search requests.

Analytics only counts aggregated queries, meaning that it waits until the user quits typing for a predetermined amount of time before it counts it is a search query.

You can learn more about how we count records and operations here. You can learn more about how we can search requests specifically here. You can learn more about the difference between how we count analytics terms and search requests here.

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.

@anduritko That is strange indeed. There are some possible noise sources that I would like to eliminate to get a better understanding of the issue at hand: Is it alright with you if we redo your experiments multiple times and change a few parameters each time?

The first thing I would consider is to avoid the indices tab in the dashboard - these queries are not counted against your plan but just to avoid any unexpected side effects. It shouldn’t have any impact, but it’s better to be safe than sorry.

Then would it be possible for you to try the following:

  1. Do one query, wait 10 mins for the analytics to report the results and note the number of searches, BUT also go in the Monitoring tab and look at the usage graphs as this is actually what’s being used for quota measurements.
  2. Repeat the process, but this time with two queries (ideally different).
  3. Repeat the process, but this time with three queries (ideally different).

The idea here is to understand whether the number of counted search grows by 12 every time you do a query or rather if there is some sort of noise that masks the actual number of searches that are processed. It is also to see if we find any differences between the Usage graphs and the Analytics graphs.

Please let me know of the results!
Best,