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
Don't consider typo in weighted token score.
Kishore Nallan6bc7817c5445
diff --git a/src/index.cpp b/src/index.cppindex 6a1f2f76..1d61061a 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -2261,7 +2261,7 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,exact_match_fields += weight;}- auto weighted_tokens_match = (tokens_found * weight) + (MAX_SUM_TYPOS - field_typos + 1);+ auto weighted_tokens_match = (tokens_found * weight);if(weighted_tokens_match > max_weighted_tokens_match) {max_weighted_tokens_match = weighted_tokens_match;}@@ -2322,7 +2322,7 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,verbatim_match_fields += weight; // this is only an approximate}- auto weighted_tokens_match = (tokens_found * weight) + (MAX_SUM_TYPOS - field_typos + 1);+ auto weighted_tokens_match = (tokens_found * weight);if(weighted_tokens_match > max_weighted_tokens_match) {max_weighted_tokens_match = weighted_tokens_match;diff --git a/test/collection_specific_test.cpp b/test/collection_specific_test.cppindex 0e3eabd3..654a156c 100644--- a/test/collection_specific_test.cpp+++ b/test/collection_specific_test.cpp@@ -218,22 +218,13 @@ TEST_F(CollectionSpecificTest, OrderMultiFieldFuzzyMatch) {ASSERT_EQ("1", results["hits"][0]["document"]["id"].get<std::string>());ASSERT_EQ("0", results["hits"][1]["document"]["id"].get<std::string>());- results = coll1->search("charger", {"title", "description"}, "", {}, {}, {2}, 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>", {2, 1}).get();-- ASSERT_EQ("1", results["hits"][0]["document"]["id"].get<std::string>());- ASSERT_EQ("0", results["hits"][1]["document"]["id"].get<std::string>());-- // use extreme weights to push title matching ahead+ // use weights to push title matching aheadresults = coll1->search("charger", {"title", "description"}, "", {}, {}, {2}, 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>", {10, 1}).get();+ "<mark>", "</mark>", {2, 1}).get();ASSERT_EQ("0", results["hits"][0]["document"]["id"].get<std::string>());ASSERT_EQ("1", results["hits"][1]["document"]["id"].get<std::string>());