From 43c26b1c7e7a130f3d741a28052dd9abe08510db Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Mon, 30 May 2022 07:13:22 +0530 Subject: [PATCH] Retain verbatim match on array. --- src/index.cpp | 6 +----- test/collection_specific_more_test.cpp | 3 ++- test/collection_test.cpp | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) 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_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) { "", "", {}, 1000, true).get(); ASSERT_EQ(2, results["hits"].size()); - ASSERT_EQ(results["hits"][0]["text_match"].get(), results["hits"][1]["text_match"].get()); + ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get().c_str()); + ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get().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()); ASSERT_EQ(2, results["hits"].size()); - ASSERT_EQ(results["hits"][0]["text_match"].get(), results["hits"][0]["text_match"].get()); + ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get().c_str()); + ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get().c_str()); collectionManager.drop_collection("coll1"); }