DEV Community

chanduthedev
chanduthedev

Posted on

ElasticSearch error message 'The [dims] property must be specified for field'

When I try to insert dense_vector values to ElasticSearch(ES), I got below error. I will explain how I resolved this error.

ES mappings

Used PUT method to create a index in ES with mappings as body

PUT http://localhost:9200/my_index

Created successfully and got below response.
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my_index"
}

But when I try to insert values, got below error for the POST request.
POST http://localhost:9200/my_index/_creat

Request Body:

{
"name": "chanduthdev",
"vector" : [ 8.56176019e-02, 6.78501204e-02]
}

Response :

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "The [dims] property must be specified for field [vector]."
}
],
"type": "mapper_parsing_exception",
"reason": "The [dims] property must be specified for field [vector]."
},
"status": 400
}

Solution:

To resolve this error, replace _creat with _doc in the url for the POST method.
POST http://localhost:9200/my_index/_doc

Response:

{
"_index": "my_index1",
"_type": "_doc",
"_id": "3VbDcHMBBskIYHrmDycX",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}

Happy Learning!!!

Top comments (0)