Error in using dynamic mapping: Elasticsearch 6.2

I have upgraded to Elasticsearch 6.2 from 5.0. I am facing challenges in dynamic template.
Template I have uploaded to ES is:

curl -XPOST localhost:9200/_template/mytemplate -H 'Content-Type: application/json' -d'
{
"index_patterns": [
"my*"
],
"settings": {
"number_of_shards": 2
},
"mappings": {
"mytype": {
"dynamic_templates": [
{
"string_fields": {
"match_mapping_type": "string",
"match": "*",
"mapping": {
"index": "not_analyzed",
"ignore_above": 256,
"type": "string"
}
}
}
],
"properties":{
"createdAt":{
"type":"date",
"format": "epoch_millis"
}
}
}
}
}'

The template is successfully loaded into elasticsearch. But when I am trying to load data into elasticSearch, its throwing following error:

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to find type parsed [string] for [fname]"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to find type parsed [string] for [fname]"
},
"status": 400
}

Data i am trying to load:

{
"fname":"aditya",
"lname":"prateek",
"createdAt":1527602481459
}

Also, I have tried giving

"mapping": {
"index": "not_analyzed",
"ignore_above": 256,
"type": "keyword"
}

But, I am getting another error: "Failed to parse value [not_analyzed] as only [true] or [false] are allowed."

Am I doing anything wrong here?

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Instead of string, use text.
Instead of "index": "not_analyzed", you can either use keyword datatype (instead of text) or use "analyzer": "keyword".

HTH

1 Like

Thanks David. I have modified the mapping to:

"mapping": {
      "ignore_above": 256,
       "type": "keyword"
}

Now its working fine. :slight_smile:

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