#random

Moving from Algolia to Typesense: Questions and Answers

TLDR Juan sought advice from Kishore Nallan about moving from Algolia to Typesense, handling MultiSearch, setting parameters, checking imported documents, and a specific syntax query.

Powered by Struct AI

1

22
20mo
Solved
Join the chat
Feb 07, 2022 (21 months ago)
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
10:33 AM
Hi guys! My company has decided to move to Typesense, we are currently using Algolia, and I will be the Developer taking care of this move. Is this the correct channel to ask technical questions?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:34 AM
Hi Juan 👋 yes. Happy to answer your questions.
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
10:43 AM
Hi Kishore, thanks!

If i were to perform a MultiSearch, would there be any way to set the amount of hits to return and also, if it was possible, how would I use "pages"? I see on the responses that there is the key page.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:44 AM
Yes, you can set a per_page and page parameters for each search query in the multi_search request.
10:46
Kishore Nallan
10:46 AM
See the multi_search example here: https://typesense.org/docs/0.22.2/api/documents.html#federated-multi-search

In this example you see two different q parameters being sent to two different collections. Likewise you can send any parameter.
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
10:47 AM
I see! All the parameters listed here https://typesense.org/docs/0.22.2/api/documents.html#search-parameters , even if they are in different "sections", they all would go in the "common parameters" object?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:49 AM
You can set both common parameters in the query string, and as well as collection-specific query parameters in the object.
10:51
Kishore Nallan
10:51 AM
Sections are just there for convenience, all of them go into the same object.

1

Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
10:52 AM
Thank you very much! For now everything is clear
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:52 AM
👍
Feb 08, 2022 (21 months ago)
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
02:20 PM
Hello again, Kishore. Checking the result of a multisearch with the following parameters: per_page: 1 :
[
  {
    facet_counts: [],
    found: 2,
    hits: [ [Object] ],
    out_of: 2,
    page: 1,
    request_params: { collection_name: 'dev_users', per_page: 1, q: 'Xh4H' },
    search_time_ms: 0
  },
  {
    facet_counts: [],
    found: 0,
    hits: [],
    out_of: 0,
    page: 1,
    request_params: { collection_name: 'dev_machines', per_page: 1, q: 'Xh4H' },
    search_time_ms: 0
  }
]

I would like to know if its possible to know if pagination is possible, currently the only way that i think its possible is by calculating the length of hits, checking out_of and also checking the current page. Is there any simpler way?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:56 PM
That's the way to know. Checking "found" value against page * per_page.
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
03:33 PM
Thank you :thumbsup:
Feb 15, 2022 (21 months ago)
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
09:53 AM
Is there any way to know how many documents were imported?
typesense.collections(environment + '_' + collection).documents().import(records, { action: 'upsert' });
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:54 AM
The response will have 1 line for each doc imported, outlining the result of that document's import. You can check to see the status of each document.
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
10:01 AM
a boolean i believe?
10:05
Juan
10:05 AM
in case one fails, how does the result look like? does it tell you which object you tried to index so that we try to re-index?
10:06
Juan
10:06 AM
in other words, if we are indexing 100 at the same time, and we only have 99 successful, how do we know which one was the one that failed?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:27 AM
When you index 100 documents, the response will have 100 lines in the same order.
10:28
Kishore Nallan
10:28 AM
See this section of the documentation for the details.
Mar 04, 2022 (20 months ago)
Juan
Photo of md5-ef165485061a49e16d6a731fcefd067b
Juan
01:01 PM
thanks 🙂

BTW, wanted to check if the syntax is correct here:
im performing a multi search in different collections with this syntax: (pic 1)
and im filtering by name, but im receiving a result that doesnt match at all (ch4pdemo)

Wanted to check if im doing anything wrong, thanks
Mar 05, 2022 (20 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:34 AM
What version of Typesense server are you using?