diff --git a/src/collection.cpp b/src/collection.cpp index 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.cpp index 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::vector> 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()); +} + TEST_F(CollectionVectorTest, VectorUnchangedUpsert) { nlohmann::json schema = R"({ "name": "coll1",