Field [_id] is defined twice in [type]

Hello,

I'm trying to give my _id a default data type so I'm defining a custom mapping for it.

PUT /test_index
{
"mappings": {
"product": {
"properties": {
"_id": {
"index": false,
"type": "keyword"
}
}
}
}
}

Error:

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [product]: Field [_id] is defined twice in [product]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [product]: Field [_id] is defined twice in [product]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Field [_id] is defined twice in [product]"
}
},
"status": 400
}

The type "product" exists in other indices, however. Is this the expected behavior? Do I need to fix my mapping on every index that has the same "product" type?

You can't define a field called _id on a type; _id is the name of a metadata field used for the id of the document.

I'd suggest naming it something else, like product_id or just id.

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