Failing with dynamic templates in ElasticSearch -


i try create simple template, including dynamic template, , can't seem index documents.

i error:

400 {"error":"mapperparsingexception[mapping [_default_]]; nested: classcastexception[java.util.linkedhashmap cannot cast java.util.list]; ","status":400} 

it works fine if remove dynaic_templates part of json.

what doing wrong?

here reproduction of code in python:

import requests import json  template = {     "template": "some_index_*",     "settings": {         "index": {             "number_of_replicas": "0",             "number_of_shards": "8",          }     },     "mappings": {         "_default_": {             "_all": {                 "enabled": false             },             "properties": {                 "h1": {                     "properties": {                         "sub1": {                             "doc_values": true,                             "type": "boolean",                             "index": "not_analyzed"                         },                         "sub2": {                             "index": "no",                             "type": "string"                         },                     }                 }             },             "dynamic_templates": {                 "text_indexed_template": {                     "match_mapping_type": "string",                     "mapping": {                         "index": "not_analyzed",                         "type": "string",                         "doc_values": true                     },                     "match": "*_idx"                 }             },             "_source": {                 "compress": false             }         }     }, }  res = requests.put(     url="http://127.0.0.1:9200/" + "_template/my_template/",     data=json.dumps(template) )  print res.status_code, res.content  new_doc = {             "h1": {                 "sub1": true,                 "sub2": "testing, testing"             }         }  res = requests.post(     url="http://127.0.0.1:9200/" + 'some_index_tryme/record/',     data=json.dumps(new_doc) )  print res.status_code, res.content 

the dynamic_templates should array of elements, meaning surrounded [ ]. so, yours should this:

  "dynamic_templates": [     {       "text_indexed_template": {         "match_mapping_type": "string",         "mapping": {           "index": "not_analyzed",           "type": "string",           "doc_values": true         },         "match": "*_idx"       }     }   ] 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -