我尝试使用映射创建单个弹性搜索索引,但得到以下错误。
from elasticsearch import Elasticsearch
es = Elasticsearch(['localhost'], verify_certs=True)
mapping = '''
{
"mappings":{
"logs_june":{
"_timestamp":{
"enabled":"true"
},
"properties":{
"logdate":{
"type":"date",
"format":"dd/MM/yyyy HH:mm:ss"
}
}
}
}
}'''
#es.indices.delete(index='test-index') #delete indexes
es.indices.create(index='test-index', ignore=400, body=mapping)
doc={
'logdate':'10/02/2016 11:22:22'
}
es.index(index='test-index',doc_type='test',body=doc)
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, u'mapper_parsing_exception', u'failed to parse [logdate]')
错误:
引起:MapperParsingException [无法解析[logdate]];嵌套:IllegalArgumentException [格式无效:" 10/02/2016 11:22:22"在" / 02/2016 11:22:22"]; at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:343) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:318) 在org.elasticsearch.index.mapper.DocumentParser.parseAndMergeUpdate(DocumentParser.java:765) 在org.elasticsearch.index.mapper.DocumentParser.parseDynamicValue(DocumentParser.java:652) 在org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:451) 在org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:271) 在org.elasticsearch.index.mapper.DocumentParser.innerParseDocument(DocumentParser.java:131) 在org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:79) 在org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:304) 在org.elasticsearch.index.shard.IndexShard.prepareCreate(IndexShard.java:500) at org.elasticsearch.index.shard.IndexShard.prepareCreateOnPrimary(IndexShard.java:481) at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:214)