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
Display vector distance metric in API response.
Kishore Nallan270561e06b0d
diff --git a/src/collection.cpp b/src/collection.cppindex 5da98b31..79172751 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -276,6 +276,7 @@ nlohmann::json Collection::get_summary_json() const {if(coll_field.num_dim > 0) {field_json[fields::num_dim] = coll_field.num_dim;+ field_json[fields::vec_dist] = magic_enum::enum_name(coll_field.vec_dist);}if (!coll_field.reference.empty()) {diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cppindex 4fcc134c..452bf076 100644--- a/test/collection_vector_search_test.cpp+++ b/test/collection_vector_search_test.cpp@@ -47,6 +47,9 @@ TEST_F(CollectionVectorTest, BasicVectorQuerying) {Collection* coll1 = collectionManager.create_collection(schema).get();+ auto coll_summary = coll1->get_summary_json();+ ASSERT_EQ("cosine", coll_summary["fields"][2]["vec_dist"].get<std::string>());+std::vector<std::vector<float>> values = {{0.851758, 0.909671, 0.823431, 0.372063},{0.97826, 0.933157, 0.39557, 0.306488},@@ -224,6 +227,22 @@ TEST_F(CollectionVectorTest, BasicVectorQuerying) {collectionManager.drop_collection("coll1");}+TEST_F(CollectionVectorTest, VectorDistanceConfig) {+ nlohmann::json schema = R"({+ "name": "coll1",+ "fields": [+ {"name": "title", "type": "string"},+ {"name": "points", "type": "int32"},+ {"name": "vec", "type": "float[]", "num_dim": 4, "vec_dist": "ip"}+ ]+ })"_json;++ Collection *coll1 = collectionManager.create_collection(schema).get();++ auto coll_summary = coll1->get_summary_json();+ ASSERT_EQ("ip", coll_summary["fields"][2]["vec_dist"].get<std::string>());+}+TEST_F(CollectionVectorTest, VectorUnchangedUpsert) {nlohmann::json schema = R"({"name": "coll1",