Skip to content

Commit

Permalink
make both approach exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
krunal1313 committed Dec 10, 2024
1 parent 61bea97 commit 74b2c5b
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3203,19 +3203,17 @@ Option<bool> Index::search(std::vector<query_tokens_t>& field_query_tokens, cons
filter_result_iterator->compute_iterators();

uint32_t filter_id_count = filter_result_iterator->approx_filter_ids_length;

if (filter_by_provided && filter_id_count < vector_query.flat_search_cutoff) {
process_results_bruteforce(filter_result_iterator, vector_query, field_vector_index, dist_results);
}

filter_result_iterator->reset();
search_cutoff = search_cutoff || filter_result_iterator->validity == filter_result_iterator_t::timed_out;

if(!filter_by_provided ||
} else if(!filter_by_provided ||
(filter_id_count >= vector_query.flat_search_cutoff && filter_result_iterator->validity == filter_result_iterator_t::valid)) {
dist_results.clear();
process_results_hnsw_index(filter_result_iterator, vector_query, field_vector_index, filterFunctor, k, dist_results, true);
}

search_cutoff = search_cutoff || filter_result_iterator->validity == filter_result_iterator_t::timed_out;

std::vector<uint32_t> nearest_ids;
std::vector<uint32_t> eval_filter_indexes;

Expand Down Expand Up @@ -3586,11 +3584,7 @@ Option<bool> Index::search(std::vector<query_tokens_t>& field_query_tokens, cons

if (filter_by_provided && filter_id_count < vector_query.flat_search_cutoff) {
process_results_bruteforce(filter_result_iterator, vector_query, field_vector_index, dist_results);
}

filter_result_iterator->reset();

if (!filter_by_provided || (filter_id_count >= vector_query.flat_search_cutoff && filter_result_iterator->validity == filter_result_iterator_t::valid)) {
} else if (!filter_by_provided || (filter_id_count >= vector_query.flat_search_cutoff && filter_result_iterator->validity == filter_result_iterator_t::valid)) {
dist_results.clear();
// use k as 100 by default for ensuring results stability in pagination
size_t default_k = 100;
Expand Down

0 comments on commit 74b2c5b

Please sign in to comment.