Getting [ERROR] 'The [dims] property must be specified for field [vector].' despite being set in mapping

I am trying to upload dense vectors to Elasticsearch endpoint.

  1. created index with mapping as below:
mapping = {
        "mappings": {
            "properties" : {
                "vector": {
                    "type": "dense_vector",
                    "dims": 100  
                    },
                "word" : {
                    "type" : "text"
                    }
                }
            }
        }  

        es.indices.create(
        index="test",
        body=mapping
    ) 

response received:

{'acknowledged': True, 'shards_acknowledged': True, 'index': 'test'}

created a function to upload vector using bulk api as below: Model is a python dictionary with word as key and associated vector as value.

def gendata(model):
  for key, value in model.items():
    key = str(key)
    yield {
        "_index": "test",
        "_id": key,
        "_type": "document",
        "word": key,
        "vector": value
    }

getting below error while calling function gendata() using helpers.bulk()

NOTE: dims are set in mapping then why it is giving error that dims must be specified.

BulkIndexError: ('100 document(s) failed to index.', [{'index': {'_index': 'glove_vocabulary_100d', '_type': 'document', '_id': 'the', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'The [dims] property must be specified for field [vector].'}, 'data': {'word': 'the', 'vector': [-0.038194, -0.24487, 0.72812, -0.39961, 0.083172, 0.043953, -0.39141, 0.3344, -0.57545, 0.087459, 0.28787, -0.06731, 0.30906, -0.26384, -0.13231, -0.20757, 0.33395, -0.33848, -0.31743, -0.48336, 0.1464, -0.37304, 0.34577, 0.052041, 0.44946, -0.46971, 0.02628, -0.54155, -0.15518, -0.14107, -0.039722, 0.28277, 0.14393, 0.23464, -0.31021, 0.086173, 0.20397, 0.52624, 0.17164, -0.082378, -0.71787, -0.41531, 0.20335, -0.12763, 0.41367, 0.55187, 0.57908, -0.33477, -0.36559, -0.54857, -0.062892, 0.26584, 0.30205, 0.99775, -0.80481, -3.0243, 0.01254, -0.36942, 2.2167, 0.72201, -0.24978, 0.92136, 0.034514, 0.46745, 1.1079, -0.19358, -0.074575, 0.23353, -0.052062, -0.22044, 0.057162, -0.15806, -0.30798, -0.41625, 0.37972, 0.15006, -0.53212, -0.2055, -1.2526, 0.071624, 0.70565, 0.49744, -0.42063, 0.26148, -1.538, -0.30223, -0.073438, -0.28312, 0.37104, -0.25217, 0.016215, -0.017099, -0.38984, 0.87424, -0.72569, -0.51058, -0.52028, -0.1459, 0.8278, 0.27062]}}}

What ES version are you using?
Do direct http request (not using a python client) work for you?

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