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

Retain verbatim match on array.

Kishore Nallan43c26b1c7e7a
diff --git a/src/index.cpp b/src/index.cpp
index 39390112..ee113163 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -4209,11 +4209,7 @@ int64_t Index::score_results2(const std::vector<sort_by> & sort_fields, const ui
auto unique_words = field_is_array ? this_words_present : ((this_match_score >> 32) & 0xFF);
auto typo_score = ((this_match_score >> 16) & 0xFF);
auto proximity = ((this_match_score >> 8) & 0xFF);
-
- // for array we have to compare with total query tokens to account for global context
- auto verbatim = field_is_array ?
- (this_match_score & 0xFF) && (int64_t)(num_query_tokens == this_words_present) :
- (this_match_score & 0xFF);
+ auto verbatim = (this_match_score & 0xFF);
if(syn_orig_num_tokens != -1 && num_query_tokens == posting_lists.size()) {
unique_words = syn_orig_num_tokens;
diff --git a/test/collection_specific_more_test.cpp b/test/collection_specific_more_test.cpp
index ef9497d3..77ffd43a 100644
--- a/test/collection_specific_more_test.cpp
+++ b/test/collection_specific_more_test.cpp
@@ -257,5 +257,6 @@ TEST_F(CollectionSpecificMoreTest, VerbatimMatchNotOnPartialTokenMatch) {
"<mark>", "</mark>", {}, 1000, true).get();
ASSERT_EQ(2, results["hits"].size());
- ASSERT_EQ(results["hits"][0]["text_match"].get<size_t>(), results["hits"][1]["text_match"].get<size_t>());
+ ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());
+ ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());
}
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index a5b8fca6..ed757fbc 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -3687,7 +3687,8 @@ TEST_F(CollectionTest, MultiFieldMatchRankingOnArray) {
ASSERT_EQ(2, results["found"].get<size_t>());
ASSERT_EQ(2, results["hits"].size());
- ASSERT_EQ(results["hits"][0]["text_match"].get<size_t>(), results["hits"][0]["text_match"].get<size_t>());
+ ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());
+ ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());
collectionManager.drop_collection("coll1");
}