【发布时间】:2016-11-21 11:50:53
【问题描述】:
我编写了以下代码来设置新索引的模板:
from elasticsearch import Elasticsearch
doc = {
"template": "te*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"type1": {
"_source": {
"enabled": "false"
},
"properties": {
"host_name": {
"type": "string",
"index": "not_analyzed"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z YYYY"
}
}
}
}
}
es = Elasticsearch([{'host': "127.0.0.1", "port": 9200}])
es.put_template("f_1", body=doc)
以下错误看起来像是一些我无法解决的语法错误:
launch(file, globals, locals) # 执行脚本
文件“/Users/D/workspace/es_index_template/create_schema.py”,第 31 行, 在 es.put_template("freshmilk_1", body=doc) 文件 "/Users/D/.virtualenvs/es_index_template/lib/python2.7/site-packages/elasticsearch/client/utils.py", 第 69 行,在 _wrapped 中 返回 func(*args, params=params, **kwargs) 文件 "/Users/D/.virtualenvs/es_index_template/lib/python2.7/site-packages/elasticsearch/client/init.py ", 第 1152 行,在 put_template 中 'template', id), params=params, body=body) 文件 "/Users/D/.virtualenvs/es_index_template/lib/python2.7/site-packages/elasticsearch/transport.py", 第 329 行,在 perform_request 中 状态、标头、数据 = connection.perform_request(方法、url、参数、正文、忽略=忽略、超时=超时)文件 "/Users/D/.virtualenvs/es_index_template/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", 第 109 行,在 perform_request 中 self._raise_error(response.status, raw_data) 文件“/Users/D/.virtualenvs/es_index_template/lib/python2.7/site-packages/elasticsearch/connection/base.py”,第 108 行,在 _raise_error 引发 HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) elasticsearch.exceptions.TransportError: TransportError(500, u'script_parse_exception', u'unexpected field [mappings]')
有人知道为什么他的映射失败了吗?
【问题讨论】:
-
你用的是什么版本的ES?
-
@Loïc:“2.1.1”谢谢!
标签: python elasticsearch