Skip to content

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

Merge branch 'v0.25-join' into v0.26-facets

Kishore Nallanbb5720955b89
diff --cc src/index.cpp
index 474f24a7,c05b8c5d..dd42727c
--- a/src/index.cpp
+++ b/src/index.cpp
@@@ -2709,33 -3224,35 +2709,45 @@@ Option<bool> Index::search(std::vector<
int64_t match_score_index = -1;
int64_t scores[3] = {0};
- compute_sort_scores(sort_fields_std, sort_order, field_values, geopoint_indices, doc_id, 0, match_score, scores, match_score_index, vec_result.second);
+ compute_sort_scores(sort_fields_std, sort_order, field_values, geopoint_indices, seq_id, 0,
+ match_score, scores, match_score_index, vec_result.second);
for(int i = 0; i < 3; i++) {
- result->scores[i] = scores[i];
+ kv->scores[i] = scores[i];
}
- result->match_score_index = match_score_index;
++
+ kv->match_score_index = match_score_index;
+
} else {
// Result has been found only in vector search: we have to add it to both KV and result_ids
// (1 / rank_of_document) * WEIGHT)
int64_t scores[3] = {0};
int64_t match_score = float_to_int64_t((1.0 / (res_index + 1)) * VECTOR_SEARCH_WEIGHT);
int64_t match_score_index = -1;
- compute_sort_scores(sort_fields_std, sort_order, field_values, geopoint_indices, doc_id, 0, match_score, scores, match_score_index, vec_result.second);
- KV kv(searched_queries.size(), doc_id, doc_id, match_score_index, scores);
+ compute_sort_scores(sort_fields_std, sort_order, field_values, geopoint_indices, seq_id, 0, match_score, scores, match_score_index, vec_result.second);
+
+ uint64_t distinct_id = seq_id;
+ if (group_limit != 0) {
+ distinct_id = get_distinct_id(group_by_fields, seq_id);
+ if(excluded_group_ids.count(distinct_id) != 0) {
+ continue;
+ }
+ }
+
+ KV kv(searched_queries.size(), seq_id, distinct_id, match_score_index, scores);
kv.text_match_score = 0;
kv.vector_distance = vec_result.second;
+
+ if (filter_result_iterator->is_valid &&
+ !filter_result_iterator->reference.empty()) {
+ // The doc_id must be valid otherwise it would've been filtered out upstream.
+ filter_result_iterator->skip_to(doc_id);
+ kv.reference_filter_results = std::move(filter_result_iterator->reference);
+ filter_result_iterator->reset();
+ }
+
topster->add(&kv);
- vec_search_ids.push_back(doc_id);
+ vec_search_ids.push_back(seq_id);
}
}