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
Support highlighting in dynamic filter query.
Kishore Nallanc2eb31d33b9c
diff --git a/src/collection.cpp b/src/collection.cppindex 5dace57b..329673dd 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -1437,16 +1437,18 @@ void Collection::highlight_result(const field &search_field,const std::string& highlight_end_tag,highlight_t & highlight) const {- if(searched_queries.size() <= field_order_kv->query_index) {- return ;- }-std::vector<art_leaf*> query_suggestion;std::set<std::string> query_suggestion_tokens;size_t qindex = 0;do {+ if(searched_queries.size() <= field_order_kv->query_index) {+ // in filter based overrides with matched tokens removal, we could have no queries but still might+ // want to highlight fields from actual query tokens+ break;+ }+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]];diff --git a/test/collection_override_test.cpp b/test/collection_override_test.cppindex c211aaf1..71032ed5 100644--- a/test/collection_override_test.cpp+++ b/test/collection_override_test.cpp@@ -886,6 +886,9 @@ TEST_F(CollectionOverrideTest, DynamicFilteringExactMatchBasics) {ASSERT_EQ("1", results["hits"][0]["document"]["id"].get<std::string>());ASSERT_EQ("0", results["hits"][1]["document"]["id"].get<std::string>());+ ASSERT_EQ("<mark>shoes</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ("<mark>shoes</mark>", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());+// should not apply filter for non-exact caseresults = coll1->search("running shoes", {"name", "category", "brand"}, "",{}, sort_fields, {2, 2, 2}, 10).get();