Skip to content

Add more distance metrics for vector fields #40473

@mayya-sharipova

Description

@mayya-sharipova
  • We would like to add more similarity/distance metrics for vectors
  • Simplify the API
GET myindex/_vectors/knnsearch
{
  "query": {
  	"match": { "my_text": "text1" }
  },
  "similarity" : "l1norm",
  "field": "my_dense_vector",
  "query_vector": [0.5, 1, -0.5]
}

This is for the simple precise knn search implemented as the sequential scan of documents filtered by the optional query.

Possible similarity metrics: cosine, dotProduct, l1norm, l2norm.
For cosine and dotProduct, a score computed as is. For l1norm and l2norm, the score is computed as 1/l1norm and 1/l2norm.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions