Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/core/ndd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,16 +1472,6 @@ class IndexManager {
}
}

std::optional<std::vector<ndd::VectorResult>> searchKNN(const std::string& index_id,
const std::vector<float>& 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<std::vector<ndd::VectorResult>>
searchKNN(const std::string& index_id,
const std::vector<float>& query,
Expand Down
15 changes: 1 addition & 14 deletions src/filter/category_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,13 @@ namespace ndd {
return bitmap.contains(id);
}

void add_batch(const std::string& field,
const std::string& value,
const std::vector<ndd::idInt>& 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<ndd::idInt>& 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);
}
Expand Down
43 changes: 3 additions & 40 deletions src/filter/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -471,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<std::string>(), 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<int>());
} else {
sortable_val = ndd::filter::float_to_sortable(value.get<float>());
}
numeric_index_->put(field, numeric_id, sortable_val);
} else if(value.is_boolean()) {
add_to_filter(field, value.get<bool>() ? "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) {
Expand Down
Loading