Spec-Zone.ru › Elasticsearch 7
›Elasticsearch Guide [7.17] ›Mapping ›Field data types

Sparse vector data type

Deprecated in 7.6.

The sparse_vector type is deprecated and will be removed in 8.0.

A sparse_vector field stores sparse vectors of float values. The maximum number of dimensions that can be in a vector should not exceed 1024. The number of dimensions can be different across documents. A sparse_vector field is a single-valued field.

These vectors can be used for document scoring. For example, a document score can represent a distance between a given query vector and the indexed document vector.

You represent a sparse vector as an object, where object fields are dimensions, and fields values are values for these dimensions. Dimensions are integer values from 0 to 65535 encoded as strings. Dimensions don’t need to be in order.

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "my_vector": {
        "type": "sparse_vector"
      },
      "my_text" : {
        "type" : "keyword"
      }
    }
  }
}
PUT my-index-000001/_doc/1
{
  "my_text" : "text1",
  "my_vector" : {"1": 0.5, "5": -0.5,  "100": 1}
}

PUT my-index-000001/_doc/2
{
  "my_text" : "text2",
  "my_vector" : {"103": 0.5, "4": -0.5,  "5": 1, "11" : 1.2}
}

Internally, each document’s sparse vector is encoded as a binary doc value. Its size in bytes is equal to 6 * NUMBER_OF_DIMENSIONS + 4, where NUMBER_OF_DIMENSIONS - number of the vector’s dimensions.

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/sparse-vector.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API