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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Fix more edge cases in highlighting.
Kishore Nallanb2c12a9b2cef
diff --git a/include/topster.h b/include/topster.hindex 5550fbd0..19ba746c 100644--- a/include/topster.h+++ b/include/topster.h@@ -16,6 +16,9 @@ struct KV {uint64_t distinct_key{};int64_t scores[3]{}; // match score + 2 custom attributes+ // to be used only in final aggregation+ uint64_t* query_indices = nullptr;+KV(uint8_t field_id, uint16_t queryIndex, uint32_t token_bits, uint64_t key, uint64_t distinct_key,uint8_t match_score_index, const int64_t *scores):field_id(field_id), match_score_index(match_score_index),@@ -27,6 +30,69 @@ struct KV {}KV() = default;++ KV(KV& kv) = default;++ KV(KV&& kv) noexcept : field_id(kv.field_id), match_score_index(kv.match_score_index),+ query_index(kv.query_index), array_index(kv.array_index), token_bits(kv.token_bits),+ key(kv.key), distinct_key(kv.distinct_key) {++ scores[0] = kv.scores[0];+ scores[1] = kv.scores[1];+ scores[2] = kv.scores[2];++ query_indices = kv.query_indices;+ kv.query_indices = nullptr;+ }++ KV& operator=(KV&& kv) noexcept {+ if (this != &kv) {+ field_id = kv.field_id;+ match_score_index = kv.match_score_index;+ query_index = kv.query_index;+ array_index = kv.array_index;+ token_bits = kv.token_bits;+ key = kv.key;+ distinct_key = kv.distinct_key;++ scores[0] = kv.scores[0];+ scores[1] = kv.scores[1];+ scores[2] = kv.scores[2];++ delete[] query_indices;+ query_indices = kv.query_indices;+ kv.query_indices = nullptr;+ }++ return *this;+ }++ KV& operator=(KV& kv) noexcept {+ if (this != &kv) {+ field_id = kv.field_id;+ match_score_index = kv.match_score_index;+ query_index = kv.query_index;+ array_index = kv.array_index;+ token_bits = kv.token_bits;+ key = kv.key;+ distinct_key = kv.distinct_key;++ scores[0] = kv.scores[0];+ scores[1] = kv.scores[1];+ scores[2] = kv.scores[2];++ delete[] query_indices;+ query_indices = kv.query_indices;+ kv.query_indices = nullptr;+ }++ return *this;+ }++ ~KV() {+ delete [] query_indices;+ query_indices = nullptr;+ }};/*diff --git a/src/collection.cpp b/src/collection.cppindex 44590a26..640e744b 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -1405,12 +1405,22 @@ void Collection::aggregate_topster(size_t query_index, Topster& agg_topster, TopTopster* group_topster = group_topster_entry.second;for(const auto& map_kv: group_topster->kv_map) {map_kv.second->query_index += query_index;+ if(map_kv.second->query_indices != nullptr) {+ for(size_t i = 0; i < map_kv.second->query_indices[0]; i++) {+ map_kv.second->query_indices[i+1] += query_index;+ }+ }agg_topster.add(map_kv.second);}}} else {for(const auto& map_kv: index_topster->kv_map) {map_kv.second->query_index += query_index;+ if(map_kv.second->query_indices != nullptr) {+ for(size_t i = 0; i < map_kv.second->query_indices[0]; i++) {+ map_kv.second->query_indices[i+1] += query_index;+ }+ }agg_topster.add(map_kv.second);}}@@ -1516,25 +1526,38 @@ void Collection::highlight_result(const field &search_field,std::vector<art_leaf*> query_suggestion;std::set<std::string> query_suggestion_tokens;- for (const art_leaf *token_leaf : searched_queries[field_order_kv->query_index]) {- // Must search for the token string fresh on that field for the given document since `token_leaf`- // is from the best matched field and need not be present in other fields of a document.- Index* index = indices[field_order_kv->key % num_memory_shards];- art_leaf *actual_leaf = index->get_token_leaf(search_field.name, &token_leaf->key[0], token_leaf->key_len);+ size_t qindex = 0;++ do {+ auto searched_query =+ (field_order_kv->query_indices == nullptr) ? searched_queries[field_order_kv->query_index] :+ searched_queries[field_order_kv->query_indices[qindex + 1]];- //LOG(INFO) << "field: " << search_field.name << ", key: " << token_leaf->key;+ for (art_leaf* token_leaf : searched_query) {+ // Must search for the token string fresh on that field for the given document since `token_leaf`+ // is from the best matched field and need not be present in other fields of a document.+ Index* index = indices[field_order_kv->key % num_memory_shards];+ art_leaf* actual_leaf = index->get_token_leaf(search_field.name, &token_leaf->key[0], token_leaf->key_len);++ if(actual_leaf == nullptr) {+ continue;+ }- if(actual_leaf != nullptr) {- query_suggestion.push_back(actual_leaf);- std::string token(reinterpret_cast<char*>(actual_leaf->key), actual_leaf->key_len-1);- query_suggestion_tokens.insert(token);- std::vector<uint16_t> positions;uint32_t doc_index = actual_leaf->values->ids.indexOf(field_order_kv->key);- auto doc_indices = new uint32_t[1];- doc_indices[0] = doc_index;- leaf_to_indices.push_back(doc_indices);+ if(doc_index != actual_leaf->values->ids.getLength()) {+ query_suggestion.push_back(actual_leaf);+ std::string token(reinterpret_cast<char*>(actual_leaf->key), actual_leaf->key_len - 1);+ //LOG(INFO) << "field: " << search_field.name << ", key: " << token;+ query_suggestion_tokens.insert(token);+ auto doc_indices = new uint32_t[1];+ doc_indices[0] = doc_index;+ leaf_to_indices.push_back(doc_indices);+ }}- }++ qindex++;+ } while(field_order_kv->query_indices != nullptr && qindex < field_order_kv->query_indices[0]);+if(query_suggestion.size() != q_tokens.size()) {// can happen for compound query matched across 2 fields when some tokens are dropped@@ -1543,6 +1566,8 @@ void Collection::highlight_result(const field &search_field,continue;}+ query_suggestion_tokens.insert(q_token);+Index* index = indices[field_order_kv->key % num_memory_shards];art_leaf *actual_leaf = index->get_token_leaf(search_field.name,reinterpret_cast<const unsigned char *>(q_token.c_str()),@@ -1638,9 +1663,10 @@ void Collection::highlight_result(const field &search_field,highlight.matched_tokens.emplace_back();std::vector<std::string>& matched_tokens = highlight.matched_tokens.back();+ bool found_first_match = false;while(tokenizer.next(raw_token, raw_token_index, tok_start, tok_end)) {- if(token_offsets.empty()) {+ if(!found_first_match) {if(snippet_start_window.size() == highlight_affix_num_tokens + 1) {snippet_start_window.pop_front();}@@ -1648,7 +1674,10 @@ void Collection::highlight_result(const field &search_field,snippet_start_window.push_back(tok_start);}- if (token_hits.count(raw_token) != 0 ||+ bool token_already_found = token_hits.count(raw_token) != 0;++ // ensures that the `snippet_start_offset` is always from a matched token, and not from query suggestion+ if ((found_first_match && token_already_found) ||(match_offset_index < match.offsets.size() &&match.offsets[match_offset_index].offset == raw_token_index)) {@@ -1661,9 +1690,15 @@ void Collection::highlight_result(const field &search_field,} while(match_offset_index < match.offsets.size() &&match.offsets[match_offset_index - 1].offset == match.offsets[match_offset_index].offset);- if(token_offsets.size() == 1) {+ if(!found_first_match) {snippet_start_offset = snippet_start_window.front();}++ found_first_match = true;++ } else if(query_suggestion_tokens.find(raw_token) != query_suggestion_tokens.end()) {+ token_offsets.emplace(tok_start, tok_end);+ token_hits.insert(raw_token);}if(raw_token_index == last_valid_offset + highlight_affix_num_tokens) {@@ -1693,6 +1728,11 @@ void Collection::highlight_result(const field &search_field,auto offset_it = token_offsets.begin();std::stringstream highlighted_text;+ // tokens from query might occur before actual snippet start offset: we skip that+ while(offset_it != token_offsets.end() && offset_it->first < snippet_start_offset) {+ offset_it++;+ }+for(size_t i = snippet_start_offset; i <= snippet_end_offset; i++) {if(offset_it != token_offsets.end()) {if (i == offset_it->first) {diff --git a/src/index.cpp b/src/index.cppindex a36a7adc..ee8debdf 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -995,6 +995,11 @@ void Index::search_candidates(const uint8_t & field_id,field_num_results += filtered_results_size;+ /*if(filtered_results_size != 0) {+ LOG(INFO) << size_t(field_id) << " - " << log_query.str() << ", filtered_results_size: " << filtered_results_size+ << ", popcount: " << (__builtin_popcount(token_bits) - 1);+ }*/+delete[] filtered_result_ids;delete[] result_ids;} else {@@ -1695,13 +1700,18 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,auto& kvs = seq_id_kvs.second; // each `kv` can be from a different fieldstd::sort(kvs.begin(), kvs.end(), Topster::is_greater);+ kvs[0]->query_indices = new uint64_t[kvs.size() + 1];+ kvs[0]->query_indices[0] = kvs.size();- // LOG(INFO) << "DOC ID: " << seq_id << ", score: " << kvs[0]->scores[kvs[0]->match_score_index];+ //LOG(INFO) << "DOC ID: " << seq_id << ", score: " << kvs[0]->scores[kvs[0]->match_score_index];// to calculate existing aggregate scores across best matching fieldsspp::sparse_hash_map<uint8_t, KV*> existing_field_kvs;- for(const auto kv: kvs) {- existing_field_kvs.emplace(kv->field_id, kv);+ for(size_t kv_i = 0; kv_i < kvs.size(); kv_i++) {+ existing_field_kvs.emplace(kvs[kv_i]->field_id, kvs[kv_i]);+ kvs[0]->query_indices[kv_i+1] = kvs[kv_i]->query_index;+ /*LOG(INFO) << "kv_i: " << kv_i << ", kvs[kv_i]->query_index: " << kvs[kv_i]->query_index << ", "+ << "searched_query: " << searched_queries[kvs[kv_i]->query_index][0];*/}uint32_t token_bits = (uint32_t(1) << 31); // top most bit set to guarantee atleast 1 bit setdiff --git a/test/collection_locale_test.cpp b/test/collection_locale_test.cppindex c6f5b63a..75fe60b1 100644--- a/test/collection_locale_test.cpp+++ b/test/collection_locale_test.cpp@@ -263,7 +263,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstThaiTextExactMatch) {ASSERT_EQ("ติดกับดัก<mark>ราย</mark><mark>ได้</mark>ปานกลาง",results["hits"][0]["highlights"][0]["snippet"].get<std::string>());- ASSERT_EQ("ข้อมูลรายคนหรือ<mark>ราย</mark>บริษัทในการเชื่อมโยงส่วน<mark>ได้</mark>ส่วนเสีย",+ ASSERT_EQ("ข้อมูล<mark>ราย</mark>คนหรือ<mark>ราย</mark>บริษัทในการเชื่อมโยงส่วน<mark>ได้</mark>ส่วนเสีย",results["hits"][1]["highlights"][0]["snippet"].get<std::string>());}diff --git a/test/collection_manager_test.cpp b/test/collection_manager_test.cppindex 8b3f507a..ac87bfc4 100644--- a/test/collection_manager_test.cpp+++ b/test/collection_manager_test.cpp@@ -232,7 +232,6 @@ TEST_F(CollectionManagerTest, RestoreRecordsOnRestart) {std::vector<std::string> facets;nlohmann::json results = collection1->search("thomas", search_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, {false}).get();- LOG(INFO) << results;ASSERT_EQ(4, results["hits"].size());std::unordered_map<std::string, field> schema = collection1->get_schema();diff --git a/test/collection_specific_test.cpp b/test/collection_specific_test.cppindex c1855479..bf74f410 100644--- a/test/collection_specific_test.cpp+++ b/test/collection_specific_test.cpp@@ -648,3 +648,75 @@ TEST_F(CollectionSpecificTest, HandleBadCharactersInStringGracefully) {collectionManager.drop_collection("coll1");}++TEST_F(CollectionSpecificTest, HighlightSecondaryFieldWithPrefixMatch) {+ std::vector<field> fields = {field("title", field_types::STRING, false),+ field("description", field_types::STRING, false),+ field("points", field_types::INT32, false),};++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields, "points").get();++ nlohmann::json doc1;+ doc1["id"] = "0";+ doc1["title"] = "Functions and Equations";+ doc1["description"] = "Use a function to solve an equation.";+ doc1["points"] = 100;++ nlohmann::json doc2;+ doc2["id"] = "1";+ doc2["title"] = "Function of effort";+ doc2["description"] = "Learn all about it.";+ doc2["points"] = 100;++ ASSERT_TRUE(coll1->add(doc1.dump()).ok());+ ASSERT_TRUE(coll1->add(doc2.dump()).ok());++ auto results = coll1->search("function", {"title", "description"}, "", {}, {}, {0}, 10,+ 1, FREQUENCY, {true, true},+ 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1}).get();++ ASSERT_EQ("0", results["hits"][0]["document"]["id"].get<std::string>());++ ASSERT_EQ(2, results["hits"][0]["highlights"].size());++ ASSERT_EQ("<mark>Functions</mark> and Equations",+ results["hits"][0]["highlights"][0]["snippet"].get<std::string>());++ ASSERT_EQ("Use a <mark>function</mark> to solve an equation.",+ results["hits"][0]["highlights"][1]["snippet"].get<std::string>());++ collectionManager.drop_collection("coll1");+}++TEST_F(CollectionSpecificTest, HighlightWithDropTokens) {+ std::vector<field> fields = {field("description", field_types::STRING, false),+ field("points", field_types::INT32, false),};++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields, "points").get();++ nlohmann::json doc1;+ doc1["id"] = "0";+ doc1["description"] = "HPE Aruba AP-575 802.11ax Wireless Access Point - TAA Compliant - 2.40 GHz, "+ "5 GHz - MIMO Technology - 1 x Network (RJ-45) - Gigabit Ethernet - Bluetooth 5";+ doc1["points"] = 100;++ ASSERT_TRUE(coll1->add(doc1.dump()).ok());++ auto results = coll1->search("HPE Aruba AP-575 Technology Gigabit Bluetooth 5", {"description"}, "", {}, {}, {0}, 10,+ 1, FREQUENCY, {true},+ 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "description", 40, {}, {}, {}, 0,+ "<mark>", "</mark>").get();++ ASSERT_EQ(1, results["hits"][0]["highlights"].size());+ ASSERT_EQ("0", results["hits"][0]["document"]["id"].get<std::string>());++ ASSERT_EQ("<mark>HPE</mark> <mark>Aruba</mark> <mark>AP-575</mark> 802.11ax Wireless Access Point - "+ "TAA Compliant - 2.40 GHz, <mark>5</mark> GHz - MIMO <mark>Technology</mark> - 1 x Network (RJ-45) - "+ "<mark>Gigabit</mark> Ethernet - <mark>Bluetooth</mark> <mark>5</mark>",+ results["hits"][0]["highlights"][0]["snippet"].get<std::string>());++ collectionManager.drop_collection("coll1");+}diff --git a/test/collection_test.cpp b/test/collection_test.cppindex 0e9221a2..8f573e6e 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -746,23 +746,23 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- ASSERT_EQ(4, results["hits"][0]["highlights"][0].size());- ASSERT_STREQ(results["hits"][0]["highlights"][0]["field"].get<std::string>().c_str(), "tags");- ASSERT_EQ(2, results["hits"][0]["highlights"][0]["snippets"].size());- ASSERT_STREQ("<mark>truth</mark>", results["hits"][0]["highlights"][0]["snippets"][0].get<std::string>().c_str());- ASSERT_STREQ("plain <mark>truth</mark>", results["hits"][0]["highlights"][0]["snippets"][1].get<std::string>().c_str());- ASSERT_EQ(2, results["hits"][0]["highlights"][0]["matched_tokens"].size());- ASSERT_STREQ("truth", results["hits"][0]["highlights"][0]["matched_tokens"][0][0].get<std::string>().c_str());- ASSERT_STREQ("truth", results["hits"][0]["highlights"][0]["matched_tokens"][1][0].get<std::string>().c_str());- ASSERT_EQ(2, results["hits"][0]["highlights"][0]["indices"].size());- ASSERT_EQ(1, results["hits"][0]["highlights"][0]["indices"][0]);- ASSERT_EQ(2, results["hits"][0]["highlights"][0]["indices"][1]);+ ASSERT_EQ(3, results["hits"][0]["highlights"][0].size());+ ASSERT_STREQ("title", results["hits"][0]["highlights"][0]["field"].get<std::string>().c_str());+ ASSERT_STREQ("Plain <mark>Truth</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>().c_str());+ ASSERT_EQ(1, results["hits"][0]["highlights"][0]["matched_tokens"].size());+ ASSERT_STREQ("Truth", results["hits"][0]["highlights"][0]["matched_tokens"][0].get<std::string>().c_str());- ASSERT_EQ(3, results["hits"][0]["highlights"][1].size());- ASSERT_STREQ("title", results["hits"][0]["highlights"][1]["field"].get<std::string>().c_str());- ASSERT_STREQ("Plain <mark>Truth</mark>", results["hits"][0]["highlights"][1]["snippet"].get<std::string>().c_str());- ASSERT_EQ(1, results["hits"][0]["highlights"][1]["matched_tokens"].size());- ASSERT_STREQ("Truth", results["hits"][0]["highlights"][1]["matched_tokens"][0].get<std::string>().c_str());+ ASSERT_EQ(4, results["hits"][0]["highlights"][1].size());+ ASSERT_STREQ(results["hits"][0]["highlights"][1]["field"].get<std::string>().c_str(), "tags");+ ASSERT_EQ(2, results["hits"][0]["highlights"][1]["snippets"].size());+ ASSERT_STREQ("<mark>truth</mark>", results["hits"][0]["highlights"][1]["snippets"][0].get<std::string>().c_str());+ ASSERT_STREQ("plain <mark>truth</mark>", results["hits"][0]["highlights"][1]["snippets"][1].get<std::string>().c_str());+ ASSERT_EQ(2, results["hits"][0]["highlights"][1]["matched_tokens"].size());+ ASSERT_STREQ("truth", results["hits"][0]["highlights"][1]["matched_tokens"][0][0].get<std::string>().c_str());+ ASSERT_STREQ("truth", results["hits"][0]["highlights"][1]["matched_tokens"][1][0].get<std::string>().c_str());+ ASSERT_EQ(2, results["hits"][0]["highlights"][1]["indices"].size());+ ASSERT_EQ(1, results["hits"][0]["highlights"][1]["indices"][0]);+ ASSERT_EQ(2, results["hits"][0]["highlights"][1]["indices"][1]);ASSERT_EQ(3, results["hits"][1]["highlights"][0].size());ASSERT_STREQ("title", results["hits"][1]["highlights"][0]["field"].get<std::string>().c_str());@@ -2456,15 +2456,15 @@ TEST_F(CollectionTest, SearchHighlightFieldFully) {spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title, tags").get();ASSERT_EQ(2, res["hits"][0]["highlights"].size());- ASSERT_EQ("<mark>LAZY</mark>", res["hits"][0]["highlights"][0]["values"][0].get<std::string>());ASSERT_EQ("The quick brown fox jumped over the <mark>lazy</mark> dog and ran straight to the forest to sleep.",- res["hits"][0]["highlights"][1]["value"].get<std::string>());+ res["hits"][0]["highlights"][0]["value"].get<std::string>());+ ASSERT_EQ(1, res["hits"][0]["highlights"][0]["matched_tokens"].size());+ ASSERT_STREQ("lazy", res["hits"][0]["highlights"][0]["matched_tokens"][0].get<std::string>().c_str());- ASSERT_EQ(1, res["hits"][0]["highlights"][1]["matched_tokens"].size());- ASSERT_STREQ("lazy", res["hits"][0]["highlights"][1]["matched_tokens"][0].get<std::string>().c_str());-- ASSERT_EQ(1, res["hits"][0]["highlights"][0]["values"][0].size());- ASSERT_STREQ("<mark>LAZY</mark>", res["hits"][0]["highlights"][0]["values"][0].get<std::string>().c_str());+ ASSERT_EQ(1, res["hits"][0]["highlights"][1]["values"].size());+ ASSERT_EQ("<mark>LAZY</mark>", res["hits"][0]["highlights"][1]["values"][0].get<std::string>());+ ASSERT_EQ(1, res["hits"][0]["highlights"][1]["snippets"].size());+ ASSERT_EQ("<mark>LAZY</mark>", res["hits"][0]["highlights"][1]["snippets"][0].get<std::string>());// excluded fields should not be returned in highlights sectionspp::sparse_hash_set<std::string> excluded_fields = {"tags"};@@ -3146,13 +3146,17 @@ TEST_F(CollectionTest, MultiFieldRelevance5) {ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("2", results["hits"][2]["document"]["id"].get<std::string>().c_str());- ASSERT_EQ(1, results["hits"][0]["highlights"].size());- ASSERT_EQ("country", results["hits"][0]["highlights"][0]["field"].get<std::string>());- ASSERT_EQ("<mark>Canada</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ(2, results["hits"][0]["highlights"].size());+ ASSERT_EQ("field_a", results["hits"][0]["highlights"][0]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canadia</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ("country", results["hits"][0]["highlights"][1]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canada</mark>", results["hits"][0]["highlights"][1]["snippet"].get<std::string>());- ASSERT_EQ(1, results["hits"][1]["highlights"].size());- ASSERT_EQ("company_name", results["hits"][1]["highlights"][0]["field"].get<std::string>());- ASSERT_EQ("<mark>Canaida</mark> Corp", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ(2, results["hits"][1]["highlights"].size());+ ASSERT_EQ("field_a", results["hits"][1]["highlights"][0]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canadoo</mark>", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ("company_name", results["hits"][1]["highlights"][1]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canaida</mark> Corp", results["hits"][1]["highlights"][1]["snippet"].get<std::string>());ASSERT_EQ(1, results["hits"][2]["highlights"].size());ASSERT_EQ("field_a", results["hits"][2]["highlights"][0]["field"].get<std::string>());@@ -3317,7 +3321,7 @@ TEST_F(CollectionTest, MultiFieldHighlighting) {ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());- ASSERT_EQ(2, results["hits"][0]["highlights"].size());+ ASSERT_EQ(3, results["hits"][0]["highlights"].size());ASSERT_EQ("name", results["hits"][0]["highlights"][0]["field"].get<std::string>());ASSERT_EQ("Best Wireless Vehicle <mark>Charger</mark>",results["hits"][0]["highlights"][0]["snippet"].get<std::string>());@@ -3326,6 +3330,9 @@ TEST_F(CollectionTest, MultiFieldHighlighting) {ASSERT_EQ("Easily replenish your cell phone with this wireless <mark>charger.</mark>",results["hits"][0]["highlights"][1]["snippet"].get<std::string>());+ ASSERT_EQ("categories", results["hits"][0]["highlights"][2]["field"].get<std::string>());+ ASSERT_EQ("Car <mark>Chargers</mark>", results["hits"][0]["highlights"][2]["snippets"][0].get<std::string>());+results = coll1->search("John With Denver",{"description"}, "", {}, {}, {0}, 10, 1, FREQUENCY,{true}, 1, spp::sparse_hash_set<std::string>(),