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.26-filter' into v0.26-filter

Kishore Nallan052d415af677
diff --cc src/index.cpp
index 4cdea5e7,f7cd7235..9c8d1b80
--- a/src/index.cpp
+++ b/src/index.cpp
@@@ -2599,8 -2794,7 +2602,8 @@@ Option<bool> Index::search(std::vector<
continue;
}
// (1 / rank_of_document) * WEIGHT)
- result->text_match_score = result->scores[result->match_score_index];
++
+ result->text_match_score = result->scores[result->match_score_index];
- LOG(INFO) << "SEQ_ID: " << result->key << ", score: " << result->text_match_score;
result->scores[result->match_score_index] = float_to_int64_t((1.0 / (i + 1)) * TEXT_MATCH_WEIGHT);
}
@@@ -2614,12 -2815,27 +2624,27 @@@
auto result = result_it->second;
// old_score + (1 / rank_of_document) * WEIGHT)
result->vector_distance = vec_result.second;
- result->scores[result->match_score_index] = float_to_int64_t((int64_t_to_float(result->scores[result->match_score_index])) + ((1.0 / (i + 1)) * VECTOR_SEARCH_WEIGHT));
+ result->scores[result->match_score_index] = float_to_int64_t(
+ (int64_t_to_float(result->scores[result->match_score_index])) +
+ ((1.0 / (res_index + 1)) * VECTOR_SEARCH_WEIGHT));
+
+ for(size_t i = 0;i < 3; i++) {
+ if(field_values[i] == &vector_distance_sentinel_value) {
+ result->scores[i] = float_to_int64_t(vec_result.second);
+ }
+
+ if(sort_order[i] == -1) {
+ result->scores[i] = -result->scores[i];
+ }
+ }
-
++
} else {
- int64_t scores[3] = {0};
+ // Result has been found only in vector search: we have to add it to both KV and result_ids
// (1 / rank_of_document) * WEIGHT)
- scores[0] = float_to_int64_t((1.0 / (i + 1)) * VECTOR_SEARCH_WEIGHT);
- int64_t match_score_index = 0;
+ 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);
kv.vector_distance = vec_result.second;
topster->add(&kv);