From 12e67b14de2cd09fdb509efc0a898fc1758b9ded Mon Sep 17 00:00:00 2001 From: Shaleen Garg Date: Mon, 30 Mar 2026 15:06:29 +0530 Subject: [PATCH 1/3] filter --- src/filter/category_index.hpp | 15 +-------------- src/filter/filter.hpp | 3 ++- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/filter/category_index.hpp b/src/filter/category_index.hpp index 58ffa62c69..7a75133601 100644 --- a/src/filter/category_index.hpp +++ b/src/filter/category_index.hpp @@ -175,26 +175,13 @@ namespace ndd { return bitmap.contains(id); } - void add_batch(const std::string& field, - const std::string& value, - const std::vector& ids) { - if(ids.empty()) { - return; - } - std::string filter_key = format_filter_key(field, value); - ndd::RoaringBitmap bitmap = get_bitmap_internal(filter_key); - for(const auto& id : ids) { - bitmap.add(id); - } - store_bitmap_internal(filter_key, bitmap); - } - // Helper for batch operations where key is already formatted void add_batch_by_key(const std::string& key, const std::vector& ids) { if(ids.empty()) { return; } ndd::RoaringBitmap bitmap = get_bitmap_internal(key); + //TODO: use addMany instead of add for(const auto& id : ids) { bitmap.add(id); } diff --git a/src/filter/filter.hpp b/src/filter/filter.hpp index 392fe2b404..9d6a18fec7 100644 --- a/src/filter/filter.hpp +++ b/src/filter/filter.hpp @@ -417,7 +417,8 @@ class Filter { } if(type == FieldType::Unknown) { - LOG_DEBUG("Unsupported filter type for field '" << field << "'"); + /*This should ideally be an error or atleast an info log.*/ + LOG_INFO("Unsupported filter type for field '" << field << "'"); continue; } From ecfaa7b99e0d3bd743c0ba8709a2a43d7e5a7762 Mon Sep 17 00:00:00 2001 From: Shaleen Garg Date: Tue, 7 Apr 2026 11:23:04 +0530 Subject: [PATCH 2/3] removing dead code --- src/core/ndd.hpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/core/ndd.hpp b/src/core/ndd.hpp index 779ba90c67..dd1fe3648b 100644 --- a/src/core/ndd.hpp +++ b/src/core/ndd.hpp @@ -1472,16 +1472,6 @@ class IndexManager { } } - std::optional> searchKNN(const std::string& index_id, - const std::vector& query, - size_t k, - const nlohmann::json& filter_array, - ndd::FilterParams params = {}, - bool include_vectors = false, - size_t ef = 0) { - return searchKNN(index_id, query, {}, {}, k, filter_array, params, include_vectors, ef); - } - std::optional> searchKNN(const std::string& index_id, const std::vector& query, From e7da08ebbad5c5aeb14ad96523c9d2862f4a46b0 Mon Sep 17 00:00:00 2001 From: Shaleen Garg Date: Wed, 15 Apr 2026 05:59:43 +0000 Subject: [PATCH 3/3] unified implementation of add_filters_from_json --- src/filter/filter.hpp | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/src/filter/filter.hpp b/src/filter/filter.hpp index 9d6a18fec7..79a6e91dd1 100644 --- a/src/filter/filter.hpp +++ b/src/filter/filter.hpp @@ -472,45 +472,7 @@ class Filter { } void add_filters_from_json(ndd::idInt numeric_id, const std::string& filter_json) { - try { - auto j = nlohmann::json::parse(filter_json); - for(const auto& [field, value] : j.items()) { - FieldType type = FieldType::Unknown; - if(value.is_boolean()) { - type = FieldType::Bool; - } else if(value.is_number()) { - type = FieldType::Number; - } else if(value.is_string()) { - type = FieldType::String; - } - - if(type == FieldType::Unknown) { - LOG_DEBUG("Unsupported filter type for field '" << field << "'"); - continue; - } - - if(!register_field_type(field, type)) { - LOG_ERROR(1205, index_id_, "Type mismatch for field '" << field << "'"); - continue; - } - - if(value.is_string()) { - add_to_filter(field, value.get(), numeric_id); - } else if(value.is_number()) { - uint32_t sortable_val; - if(value.is_number_integer()) { - sortable_val = ndd::filter::int_to_sortable(value.get()); - } else { - sortable_val = ndd::filter::float_to_sortable(value.get()); - } - numeric_index_->put(field, numeric_id, sortable_val); - } else if(value.is_boolean()) { - add_to_filter(field, value.get() ? "1" : "0", numeric_id); - } - } - } catch(const std::exception& e) { - LOG_ERROR(1206, index_id_, "Error adding filters: " << e.what()); - } + add_filters_from_json_batch({{numeric_id, filter_json}}); } void remove_filters_from_json(ndd::idInt numeric_id, const std::string& filter_json) {