[role="xpack"]
[testenv="basic"]
[[dense-vector]]
=== Dense vector field type
++++
<titleabbrev>Dense vector</titleabbrev>
++++

A `dense_vector` field stores dense vectors of float values.
The maximum number of dimensions that can be in a vector should
not exceed 2048. A `dense_vector` field is a single-valued field.

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

You index a dense vector as an array of floats.

[source,console]
--------------------------------------------------
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "my_vector": {
        "type": "dense_vector",
        "dims": 3  <1>
      },
      "my_text" : {
        "type" : "keyword"
      }
    }
  }
}

PUT my-index-000001/_doc/1
{
  "my_text" : "text1",
  "my_vector" : [0.5, 10, 6]
}

PUT my-index-000001/_doc/2
{
  "my_text" : "text2",
  "my_vector" : [-0.5, 10, 10]
}

--------------------------------------------------

<1> dims—the number of dimensions in the vector, required parameter.

Internally, each document's dense vector is encoded as a binary
doc value. Its size in bytes is equal to
`4 * dims + 4`, where `dims`—the number of the vector's dimensions.
