Feature vector datatypeedit

A feature_vector field can index numeric feature vectors, so that they can later be used to boost documents in queries with a feature query.

It is analogous to the feature datatype but is better suited when the list of features is sparse so that it wouldn’t be reasonable to add one field to the mappings for each of them.

PUT my_index?include_type_name=true
{
  "mappings": {
    "_doc": {
      "properties": {
        "topics": {
          "type": "feature_vector" 
        }
      }
    }
  }
}

PUT my_index/_doc/1
{
  "topics": { 
    "politics": 20,
    "economics": 50.8
  }
}

PUT my_index/_doc/2
{
  "topics": {
    "politics": 5.2,
    "sports": 80.1
  }
}

GET my_index/_search
{
  "query": {
    "feature": {
      "field": "topics.politics"
    }
  }
}

Feature vector fields must use the feature_vector field type

Feature vector fields must be a hash with string keys and strictly positive numeric values

Note

feature_vector fields only support single-valued features and strictly positive values. Multi-valued fields and zero or negative values will be rejected.

Note

feature_vector fields do not support sorting or aggregating and may only be queried using feature queries.

Note

feature_vector fields only preserve 9 significant bits for the precision, which translates to a relative error of about 0.4%.