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
Allow exact matches on longer strings.
Kishore Nallan59e1fd0e4f65
diff --git a/src/index.cpp b/src/index.cppindex d935d5e0..95772c48 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -2776,7 +2776,8 @@ void Index::fuzzy_search_fields(const std::vector<search_field_t>& the_fields,auto product = []( long long a, std::vector<int>& b ) { return a*b.size(); };long long n = 0;- long long int N = std::accumulate(token_to_costs.begin(), token_to_costs.end(), 1LL, product);+ long long int N = token_to_costs.size() > 30 ? 1 :+ std::accumulate(token_to_costs.begin(), token_to_costs.end(), 1LL, product);const long long combination_limit = exhaustive_search ? Index::COMBINATION_MAX_LIMIT : Index::COMBINATION_MIN_LIMIT;diff --git a/test/collection_specific_more_test.cpp b/test/collection_specific_more_test.cppindex 4921eba7..d865f496 100644--- a/test/collection_specific_more_test.cpp+++ b/test/collection_specific_more_test.cpp@@ -723,3 +723,28 @@ TEST_F(CollectionSpecificMoreTest, OrderWithThreeSortFields) {collectionManager.drop_collection("coll1");}++TEST_F(CollectionSpecificMoreTest, LongString) {+ std::vector<field> fields = {field("name", field_types::STRING, false),};++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();++ std::string name;+ for(size_t i = 0; i < 100; i++) {+ name += "foo" + std::to_string(i) + " ";+ }++ nlohmann::json doc1;+ doc1["name"] = name;++ ASSERT_TRUE(coll1->add(doc1.dump()).ok());++ auto results = coll1->search(name, {"name"},+ "", {}, sort_fields, {2}, 10,+ 1, FREQUENCY, {true},+ 0).get();++ ASSERT_EQ(1, results["hits"].size());++ collectionManager.drop_collection("coll1");+}