mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 13:12:22 +08:00
Display vector distance metric in API response.
This commit is contained in:
parent
ede35e7d5e
commit
270561e06b
@ -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()) {
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user