I’m trying to build a file uploader which creates ...
# community-help
w
I’m trying to build a file uploader which creates a typesense document after the file is uploaded. when i use the typesense ruby api to create a document with A_object.index!, can i assume that the document will be created in the collection the moment the command is executed, or there’s internal batching over at typesense? I realize that i don’t see the new document after refreshing the api call to my backend when the uploader successfully uploads the file.
f
Typesense server will return a HTTP response based on if the import operation has been executed successfully. If it is successful, then it should be visible on your collection
w
I don't think the index! Function in ruby typesense returns a response. How can we then wait the response for that call?
f
Is the response successful? The
import
endpoint returns a list of JSON objects indicating whether the import was successful or not, with an error code for each import failiure
The
import
endpoint will return a 200 regardless of whether or not every import statement is successful
w
While the api returns the response, do you know if this library will return the response from the api? I realize i was using the typesense-rails library with the index! function: https://github.com/typesense/typesense-rails/
f
The original package was issued by Algolia and has it's own docs. Have you tried logging the response of the
index!
method?
w
index! returns a nil or null response, we can’t use it effectively.
also i would like to know if API calls aare subjected to the effects of delayed response in a HA cluster setup, as noted here. Is it expected that there could be delays in API responses, and for indexing to fully replicate the data across the 3 nodes in the cluster? https://typesense.org/docs/guide/high-availability.html
f
During indexing, since the data needs to be replicated across the nodes for redundancy purposes, you should expect some spikes in CPU usage, though it shouldn't pose any significant delays itself.
does using the
reindex
method return anything?
w
No it doesn't. It returns nil right at the end too.
Any chance of making the api returns a response for these 2 functions?
f
Will look into it!
Could you take a look at https://github.com/typesense/typesense-rails/pull/3 to verify?
w
yeah it looks good
if there’s an api response for import, it means the document has been created on typesense, even if there’s delays due to index replication across HA clusters. Is my understanding correct?
f
Correct!
👍 1