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
Aggregate match score when matched across array elements.
kishorencf4423367c856
diff --git a/src/index.cpp b/src/index.cppindex de895219..07b23b7f 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -1524,10 +1524,24 @@ void Index::search(Option<uint32_t> & outcome,art_fuzzy_search(search_index.at(field), (const unsigned char *) token.c_str(), token_len,0, 0, 1, token_order, prefix_search, leaves);- if(!leaves.empty() && leaves[0]->values->ids.contains(seq_id)) {- words_present++;+ if(leaves.empty()) {+ continue;+ }++ uint32_t doc_index = leaves[0]->values->ids.indexOf(seq_id);++ if (doc_index == leaves[0]->values->ids.getLength()) {+ continue;}+ uint32_t start_offset = leaves[0]->values->offset_index.at(doc_index);+ uint32_t end_offset = (doc_index == leaves[0]->values->ids.getLength() - 1) ?+ leaves[0]->values->offsets.getLength() :+ leaves[0]->values->offset_index.at(doc_index+1);++ words_present += (end_offset - start_offset);+ int k = 10;+/*if(!leaves.empty()) {LOG(INFO) << "tok: " << leaves[0]->key;}*/@@ -1810,9 +1824,7 @@ void Index::score_results(const std::vector<sort_by> & sort_fields, const uint16const Match & match = Match(seq_id, token_positions, false);uint64_t this_match_score = match.get_match_score(total_cost, field_id);- if(this_match_score > match_score) {- match_score = this_match_score;- }+ match_score += this_match_score;/*std::ostringstream os;os << name << ", total_cost: " << (255 - total_cost)diff --git a/test/collection_test.cpp b/test/collection_test.cppindex fa783292..7c412c3a 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -2708,6 +2708,48 @@ TEST_F(CollectionTest, MultiFieldMatchRanking) {collectionManager.drop_collection("coll1");}+TEST_F(CollectionTest, MultiFieldMatchRankingOnArray) {+ Collection *coll1;++ std::vector<field> fields = {field("name", field_types::STRING, false),+ field("strong_skills", field_types::STRING_ARRAY, false),+ field("skills", field_types::STRING_ARRAY, false),+ field("points", field_types::INT32, false),};++ coll1 = collectionManager.get_collection("coll1");+ if(coll1 == nullptr) {+ coll1 = collectionManager.create_collection("coll1", 1, fields, "points").get();+ }++ std::vector<std::vector<std::vector<std::string>>> records = {+ {{"John Snow"}, {"Golang", "Vue", "React"}, {"Docker", "Goa", "Elixir"}},+ {{"Jack Dan"}, {"Golang", "Phoenix", "React"}, {"Docker", "Vue", "Kubernetes"}},+ };++ for(size_t i=0; i<records.size(); i++) {+ nlohmann::json doc;++ doc["id"] = std::to_string(i);+ doc["name"] = records[i][0][0];+ doc["strong_skills"] = records[i][1];+ doc["skills"] = records[i][2];+ doc["points"] = i;++ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ auto results = coll1->search("golang vue",+ {"strong_skills", "skills"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();++ ASSERT_EQ(2, results["found"].get<size_t>());+ ASSERT_EQ(2, results["hits"].size());++ 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");+}+TEST_F(CollectionTest, HighlightWithAccentedCharacters) {Collection *coll1;