# Dense\_vector becomes type "float"

**URL:** <https://discuss.elastic.co/t/dense-vector-becomes-type-float/258330>\
**Category:** Elasticsearch\
**Created:** [December 10, 2020, 7:31pm UTC](https://discuss.elastic.co/t/dense-vector-becomes-type-float/258330 "2020-12-10T19:31:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![miya2](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@miya2](https://discuss.elastic.co/u/miya2)\
**Post date:** [December 10, 2020, 7:31pm UTC](https://discuss.elastic.co/t/dense-vector-becomes-type-float/258330/1 "2020-12-10T19:31:53Z")

</div>

Hi,  
I'm trying to load vector\_value into elastic search,  
and loading finished without any error.  
But the result of mapping shows type "float", not "dense\_vector".  
The version of Elasticsearch is 7.5.0.

```auto
{
  "test" : {
    "mappings" : {
      "properties" : {
        "text" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "text_feature" : {
          "type" : "float"
        }
      }
    }
  }
}

```

I'm using following python code for loading.

```auto
import csv
import os
import sys
from elasticsearch import Elasticsearch, helpers
import yaml
from my_vectorizer import MySentenceVectorizer
VEC = MyVectorizer()

def create_index(index='test'):
    es = Elasticsearch()

    setting = yaml.load(open('./mapping.yaml'), Loader=yaml.SafeLoader)
    properties = setting['mappings']['properties']

    def generate_data():
        with open('./text.csv', 'r') as f:
            reader = csv.reader(f)
            attrs = next(reader)
            for lid, row in enumerate(reader):
                data = {
                    '_op_type': 'index',
                    '_index': index,
                }
                for j, value in enumerate(row):
                    if attrs[j] in properties:
                        data[attrs[j]] = value
                    if attrs[j] == 'text':
                        data['text_vector'] = VEC.vectorize(value).tolist()

                yield data

    print(helpers.bulk(es, generate_data()))

create_index()

```

The type of variable " VEC.vectorize(value).tolist()" is surely list object of float.  
And my yaml settings is as follows.

```auto
settings:
  index:
    analysis:
      analyzer:
        my_analyzer:
          type: custom
          tokenizer: kuromoji_tokenizer
          filter:
            - kuromoji_baseform
mappings:
  properties:
    text:
      type: text
      index: true
      fielddata: true
      analyzer: my_analyzer
    text_feature:
      type: dense_vector
      dims: 768

```

The vector value is generated by BERT vectorizer.  
I'm completely stuck in this situation.  
I hope someone help me.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 7, 2021, 7:31pm UTC](https://discuss.elastic.co/t/dense-vector-becomes-type-float/258330/2 "2021-01-07T19:31:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
