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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Add cli flag for enabling lazy filter. Disable by default.
Kishore Nallan4328ee359c14
diff --git a/include/collection.h b/include/collection.hindex b4e36cbe..73604669 100644--- a/include/collection.h+++ b/include/collection.h@@ -585,7 +585,7 @@ public:const std::string& override_tags_str = "",const std::string& voice_query = "",bool enable_typos_for_numerical_tokens = true,- bool enable_lazy_filter = true) const;+ bool enable_lazy_filter = false) const;Option<bool> get_filter_ids(const std::string & filter_query, filter_result_t& filter_result) const;diff --git a/include/index.h b/include/index.hindex 4347cc9f..1bffb855 100644--- a/include/index.h+++ b/include/index.h@@ -693,7 +693,7 @@ public:const drop_tokens_param_t drop_tokens_mode,facet_index_type_t facet_index_type = DETECT,bool enable_typos_for_numerical_tokens = true,- bool enable_lazy_filter = true+ bool enable_lazy_filter = false) const;void remove_field(uint32_t seq_id, const nlohmann::json& document, const std::string& field_name,diff --git a/include/tsconfig.h b/include/tsconfig.hindex 1d90309f..b879873b 100644--- a/include/tsconfig.h+++ b/include/tsconfig.h@@ -76,6 +76,8 @@ private:uint32_t db_compaction_interval;+ bool enable_lazy_filter;+bool enable_search_logging;protected:@@ -108,6 +110,8 @@ protected:this->housekeeping_interval = 1800; // in secondsthis->db_compaction_interval = 0; // in seconds, disabled+ this->enable_lazy_filter = false;+this->enable_search_logging = false;}@@ -366,6 +370,10 @@ public:return this->log_dir + "/typesense-access.log";}+ bool get_enable_lazy_filter() const {+ return enable_lazy_filter;+ }+const std::atomic<bool>& get_skip_writes() const {return skip_writes;}diff --git a/src/collection_manager.cpp b/src/collection_manager.cppindex 7fa1cc8f..75b7fa4f 100644--- a/src/collection_manager.cpp+++ b/src/collection_manager.cpp@@ -1596,7 +1596,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& rebool enable_highlight_v1 = true;text_match_type_t match_type = max_score;bool enable_typos_for_numerical_tokens = true;- bool enable_lazy_filter = true;+ bool enable_lazy_filter = Config::get_instance().get_enable_lazy_filter();size_t remote_embedding_timeout_ms = 5000;size_t remote_embedding_num_tries = 2;diff --git a/src/tsconfig.cpp b/src/tsconfig.cppindex 51113b3c..d1967ac0 100644--- a/src/tsconfig.cpp+++ b/src/tsconfig.cpp@@ -251,6 +251,7 @@ void Config::load_config_env() {}this->skip_writes = ("TRUE" == get_env("TYPESENSE_SKIP_WRITES"));+ this->enable_lazy_filter = ("TRUE" == get_env("TYPESENSE_ENABLE_LAZY_FILTER"));this->reset_peers_on_error = ("TRUE" == get_env("TYPESENSE_RESET_PEERS_ON_ERROR"));}@@ -437,6 +438,11 @@ void Config::load_config_file(cmdline::parser& options) {this->memory_used_max_percentage = (int) reader.GetInteger("server", "memory-used-max-percentage", 100);}+ if(reader.Exists("server", "enable-lazy-filter")) {+ auto enable_lazy_filter_str = reader.Get("server", "enable-lazy-filter", "false");+ this->enable_lazy_filter = (enable_lazy_filter_str == "true");+ }+if(reader.Exists("server", "skip-writes")) {auto skip_writes_str = reader.Get("server", "skip-writes", "false");this->skip_writes = (skip_writes_str == "true");@@ -611,6 +617,10 @@ void Config::load_config_cmd_args(cmdline::parser& options) {this->enable_search_analytics = options.get<bool>("enable-search-analytics");}+ if(options.exist("enable-lazy-filter")) {+ this->enable_lazy_filter = options.get<bool>("enable-lazy-filter");+ }+if(options.exist("enable-search-logging")) {this->enable_search_logging = options.get<bool>("enable-search-logging");}diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cppindex 37459cb5..c0379461 100644--- a/src/typesense_server_utils.cpp+++ b/src/typesense_server_utils.cpp@@ -112,6 +112,7 @@ void init_cmdline_options(cmdline::parser & options, int argc, char **argv) {options.add<int>("cache-num-entries", '\0', "Number of entries to cache.", false, 1000);options.add<uint32_t>("analytics-flush-interval", '\0', "Frequency of persisting analytics data to disk (in seconds).", false, 3600);options.add<uint32_t>("housekeeping-interval", '\0', "Frequency of housekeeping background job (in seconds).", false, 1800);+ options.add<bool>("enable-lazy-filter", '\0', "Filter clause will be evaluated lazily.", false, false);options.add<uint32_t>("db-compaction-interval", '\0', "Frequency of RocksDB compaction (in seconds).", false, 604800);// DEPRECATED