Retain verbatim match on array.

This commit is contained in:
Kishore Nallan 2022-05-30 07:13:22 +05:30
parent a409df8dad
commit 43c26b1c7e
3 changed files with 5 additions and 7 deletions

View File

@ -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;

View File

@ -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());
}

View File

@ -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");
}