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

Parsed field name in vector query should be trimmed.

Kishore Nallanf455cbc293f8
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index bb16f799..742ea395 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -1416,6 +1416,8 @@ bool CollectionManager::parse_vector_query_str(std::string vector_query_str, vec
// field name is done
i++;
+ StringUtils::trim(vector_query.field_name);
+
while(i < vector_query_str.size() && vector_query_str[i] != '(') {
i++;
}
diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cpp
index 59bef26f..18467fa2 100644
--- a/test/collection_vector_search_test.cpp
+++ b/test/collection_vector_search_test.cpp
@@ -109,6 +109,17 @@ TEST_F(CollectionVectorTest, BasicVectorQuerying) {
ASSERT_STREQ("1", results["hits"][0]["document"]["id"].get<std::string>().c_str());
ASSERT_STREQ("0", results["hits"][1]["document"]["id"].get<std::string>().c_str());
+ // must trim space after field name
+ results = coll1->search("*", {}, "", {}, {}, {0}, 10, 1, FREQUENCY, {true}, Index::DROP_TOKENS_THRESHOLD,
+ spp::sparse_hash_set<std::string>(),
+ spp::sparse_hash_set<std::string>(), 10, "", 30, 5,
+ "", 10, {}, {}, {}, 0,
+ "<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7, fallback,
+ 4, {off}, 32767, 32767, 2,
+ false, true, "vec :([0.96826, 0.94, 0.39557, 0.306488])").get();
+
+ ASSERT_EQ(3, results["found"].get<size_t>());
+
// validate wrong dimensions in query
auto res_op = coll1->search("*", {}, "", {}, {}, {0}, 10, 1, FREQUENCY, {true}, Index::DROP_TOKENS_THRESHOLD,
spp::sparse_hash_set<std::string>(),