fix(search): validate filters and reset stale filter state (#663)
This commit is contained in:
parent
f4aa7845f2
commit
e1f11e29fe
|
|
@ -57,8 +57,10 @@ int FlatIndex::_prepare_for_search(
|
|||
|
||||
context->set_topk(flat_search_param->topk);
|
||||
context->set_fetch_vector(flat_search_param->fetch_vector);
|
||||
if (flat_search_param->filter) {
|
||||
if (flat_search_param->filter && flat_search_param->filter->is_valid()) {
|
||||
context->set_filter(std::move(*flat_search_param->filter));
|
||||
} else {
|
||||
context->reset_filter();
|
||||
}
|
||||
if (flat_search_param->radius > 0.0f) {
|
||||
context->set_threshold(flat_search_param->radius);
|
||||
|
|
@ -69,4 +71,4 @@ int FlatIndex::_prepare_for_search(
|
|||
}
|
||||
|
||||
|
||||
} // namespace zvec::core_interface
|
||||
} // namespace zvec::core_interface
|
||||
|
|
|
|||
|
|
@ -154,8 +154,10 @@ int HNSWIndex::_prepare_for_search(
|
|||
|
||||
context->set_topk(hnsw_search_param->topk);
|
||||
context->set_fetch_vector(hnsw_search_param->fetch_vector);
|
||||
if (hnsw_search_param->filter) {
|
||||
if (hnsw_search_param->filter && hnsw_search_param->filter->is_valid()) {
|
||||
context->set_filter(std::move(*hnsw_search_param->filter));
|
||||
} else {
|
||||
context->reset_filter();
|
||||
}
|
||||
if (hnsw_search_param->radius > 0.0f) {
|
||||
context->set_threshold(hnsw_search_param->radius);
|
||||
|
|
|
|||
|
|
@ -113,8 +113,10 @@ int HNSWRabitqIndex::_prepare_for_search(
|
|||
|
||||
context->set_topk(hnsw_search_param->topk);
|
||||
context->set_fetch_vector(hnsw_search_param->fetch_vector);
|
||||
if (hnsw_search_param->filter) {
|
||||
if (hnsw_search_param->filter && hnsw_search_param->filter->is_valid()) {
|
||||
context->set_filter(std::move(*hnsw_search_param->filter));
|
||||
} else {
|
||||
context->reset_filter();
|
||||
}
|
||||
if (hnsw_search_param->radius > 0.0f) {
|
||||
context->set_threshold(hnsw_search_param->radius);
|
||||
|
|
|
|||
|
|
@ -221,8 +221,10 @@ int IVFIndex::_prepare_for_search(
|
|||
|
||||
context->set_topk(ivf_search_param->topk);
|
||||
context->set_fetch_vector(ivf_search_param->fetch_vector);
|
||||
if (ivf_search_param->filter) {
|
||||
if (ivf_search_param->filter && ivf_search_param->filter->is_valid()) {
|
||||
context->set_filter(std::move(*ivf_search_param->filter));
|
||||
} else {
|
||||
context->reset_filter();
|
||||
}
|
||||
if (ivf_search_param->radius > 0.0f) {
|
||||
context->set_threshold(ivf_search_param->radius);
|
||||
|
|
@ -270,4 +272,4 @@ int IVFIndex::Merge(const std::vector<Index::Pointer> &indexes,
|
|||
is_trained_ = true;
|
||||
return 0;
|
||||
}
|
||||
} // namespace zvec::core_interface
|
||||
} // namespace zvec::core_interface
|
||||
|
|
|
|||
|
|
@ -86,8 +86,10 @@ int VamanaIndex::_prepare_for_search(
|
|||
|
||||
context->set_topk(vamana_search_param->topk);
|
||||
context->set_fetch_vector(vamana_search_param->fetch_vector);
|
||||
if (vamana_search_param->filter) {
|
||||
if (vamana_search_param->filter && vamana_search_param->filter->is_valid()) {
|
||||
context->set_filter(std::move(*vamana_search_param->filter));
|
||||
} else {
|
||||
context->reset_filter();
|
||||
}
|
||||
if (vamana_search_param->radius > 0.0f) {
|
||||
context->set_threshold(vamana_search_param->radius);
|
||||
|
|
|
|||
Loading…
Reference in New Issue