Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Return timeout early for backlogged embedding requests.

Kishore Nallan7c55daf07c41
diff --git a/src/collection.cpp b/src/collection.cpp
index 458df719..8036da34 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -1240,6 +1240,14 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
if(!embedder_op.ok()) {
return Option<nlohmann::json>(400, embedder_op.error());
}
+
+ auto remote_embedding_timeout_us = remote_embedding_timeout_ms * 1000;
+ if((std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::system_clock::now().time_since_epoch()).count() - search_begin_us) > remote_embedding_timeout_us) {
+ std::string error = "Request timed out.";
+ return Option<nlohmann::json>(500, error);
+ }
+
auto embedder = embedder_op.get();
if(embedder->is_remote()) {