Map a vector distance function name to its `DistanceMetric`. `vector_distance` (and the rewritten `<->` operator) → L2; `vector_cosine_distance` (and `<=>`) → Cosine; `vector_neg_inner_product` (and `<#>`) → InnerProduct. Unknown names default to L2 — callers must gate on a `VectorSearch` search-trigger before invoking this so unknown names cannot leak in.
(name: &str)
| 193 | /// Unknown names default to L2 — callers must gate on a `VectorSearch` |
| 194 | /// search-trigger before invoking this so unknown names cannot leak in. |
| 195 | pub(super) fn metric_from_func_name(name: &str) -> DistanceMetric { |
| 196 | if name.eq_ignore_ascii_case("vector_cosine_distance") { |
| 197 | DistanceMetric::Cosine |
| 198 | } else if name.eq_ignore_ascii_case("vector_neg_inner_product") { |
| 199 | DistanceMetric::InnerProduct |
| 200 | } else { |
| 201 | DistanceMetric::L2 |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /// Extract a float array from ARRAY[...], make_array(...), or a JSON-array |
| 206 | /// string literal like `'[1.0, 0.5, 0.0]'`. |
no outgoing calls
no test coverage detected