I am new to elastic search and i am trying to create a mapping file for an index this is my mapping file for creating an index
{
"mapping": {
"properties": {
"TotalCapacity": {
"type": "long"
},
"DiskUseState": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
},
"DriveHostName": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
},
"ModelNumber": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
},
"DriveNodeUuid": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
},
"DrivePath": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
},
"DriveProtocol": {
"type": "text",
"fields": {
"type": "keyword",
"ignored_above": 256
}
}
}
}
}
when i try to create an index iam getting this error
'mapper_parsing_exception' illegal field [ignored_above], only fields can be specified inside fields' error in elastic search.
Not sure whats wrong . Any help is appriciated Elasticsearch version : 7.1.0
CodePudding user response:
You have 2 issue with your mapping configuration:
First, it should ignore_above
and not ignored_above
.
Second, You have not given sub field name. your field mapping should be something like below, so you can access keyword
type of field using DiskUseState.keyword
name:
"DiskUseState": {
"type": "text",
"fields": {
"keyword": { <---- this you have not given in your mapping
"type": "keyword",
"ignore_above": 256
}
}
}
Correct field mapping
{
"mappings": {
"properties": {
"TotalCapacity": {
"type": "long"
},
"DiskUseState": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"DriveHostName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"ModelNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"DriveNodeUuid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"DrivePath": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"DriveProtocol": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}