Skip to content

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

Fix a bug in phrase search + filtering.

Kishore Nallan5b4b723672b8
diff --git a/src/index.cpp b/src/index.cpp
index 4f33b5ee..d5c91d35 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -2206,6 +2206,10 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,
}
}
+ if(!field_query_tokens[i].q_phrases.empty() && phrase_match_ids_size == 0) {
+ continue;
+ }
+
auto actual_filter_ids = filter_ids;
auto actual_filter_ids_length = filter_ids_length;
@@ -2319,7 +2323,7 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,
}
if(phrase_match_ids_size != 0) {
- delete actual_filter_ids;
+ delete [] actual_filter_ids;
}
}
diff --git a/test/collection_specific_test.cpp b/test/collection_specific_test.cpp
index 271bb1db..0d1dc059 100644
--- a/test/collection_specific_test.cpp
+++ b/test/collection_specific_test.cpp
@@ -2241,6 +2241,11 @@ TEST_F(CollectionSpecificTest, PhraseSearchMultipleFields) {
ASSERT_EQ(1, results["hits"].size());
+ results = coll1->search(R"("dog and cat")", {"title", "description"},
+ "description: about", {}, {}, {2, 2}, 10, 1, FREQUENCY, {true, true}, 10).get();
+
+ ASSERT_EQ(1, results["hits"].size());
+
collectionManager.drop_collection("coll1");
}