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

Return collection name as part of search response.

kishorenc6de60867d8c5
diff --git a/src/collection.cpp b/src/collection.cpp
index 09e9858f..615da9f3 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -1170,6 +1170,7 @@ Option<nlohmann::json> Collection::search(const std::string & query, const std::
}
result["request_params"] = nlohmann::json::object();;
+ result["request_params"]["collection_name"] = name;
result["request_params"]["per_page"] = per_page;
result["request_params"]["q"] = query;
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index c21c07f3..0ef3b3bc 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -109,6 +109,7 @@ TEST_F(CollectionTest, ExactSearchShouldBeStable) {
ASSERT_EQ(7, results["hits"].size());
ASSERT_EQ(7, results["found"].get<int>());
+ ASSERT_STREQ("collection", results["request_params"]["collection_name"].get<std::string>().c_str());
ASSERT_STREQ("the", results["request_params"]["q"].get<std::string>().c_str());
ASSERT_EQ(10, results["request_params"]["per_page"].get<size_t>());