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

Initialize thread locals earlier.

Kishore Nallande07f89e4789
diff --git a/src/collection.cpp b/src/collection.cpp
index e5ee2c4b..8596f2a6 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -725,6 +725,11 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
std::shared_lock lock(mutex);
+ // setup thread local vars
+ search_stop_ms = search_stop_millis;
+ search_begin = std::chrono::high_resolution_clock::now();
+ search_cutoff = false;
+
if(raw_query != "*" && search_fields.empty()) {
return Option<nlohmann::json>(400, "No search fields specified for the query.");
}
diff --git a/src/index.cpp b/src/index.cpp
index e02d33d7..912069ef 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -2147,10 +2147,6 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens, const std::v
const size_t max_extra_suffix, const size_t facet_query_num_typos,
const bool filter_curated_hits, const bool split_join_tokens) const {
- search_begin = std::chrono::high_resolution_clock::now();
- search_stop_ms = search_cutoff_ms;
- search_cutoff = false;
-
// process the filters
uint32_t* filter_ids = nullptr;