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
Fixed an edge case in highlight of prefix.
Kishore Nallan4844f19c5018
diff --git a/src/collection.cpp b/src/collection.cppindex 329673dd..f2268a72 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -1632,7 +1632,7 @@ void Collection::highlight_result(const field &search_field,found_first_match = true;} else if(query_suggestion_tokens.find(raw_token) != query_suggestion_tokens.end() ||- raw_token.rfind(prefix_token, 0) == 0 || prefix_token.rfind(raw_token, 0) == 0) {+ raw_token.rfind(prefix_token, 0) == 0) {token_offsets.emplace(tok_start, tok_end);token_hits.insert(raw_token);}diff --git a/test/collection_specific_test.cpp b/test/collection_specific_test.cppindex 5c44b666..55de988f 100644--- a/test/collection_specific_test.cpp+++ b/test/collection_specific_test.cpp@@ -1698,3 +1698,26 @@ TEST_F(CollectionSpecificTest, RepeatingStringArrayTokens) {collectionManager.drop_collection("coll1");}++TEST_F(CollectionSpecificTest, HighlightOnPrefixRegression) {+ std::vector<std::string> tags;++ // when the first document containing a token already cannot fit compact posting list++ std::vector<field> fields = {field("title", field_types::STRING, false),};++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();++ nlohmann::json doc;+ doc["title"] = "And then there were a storm.";++ ASSERT_TRUE(coll1->add(doc.dump()).ok());++ auto results = coll1->search("and", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY, {false}).get();+ ASSERT_EQ(1, results["hits"].size());++ LOG(INFO) << results;++ collectionManager.drop_collection("coll1");+}+