Я пытаюсь запустить следующий код и получаю исключение 'mapper_parsing_exception'.Этот пример взят из документации для Elasticsearch 6.1.1
from elasticsearch import Elasticsearch
import logging
import sys
logger = logging.getLogger(__name__)
es_host = {'host': 'localhost', 'port': 9200}
elastic_con = Elasticsearch(hosts=[es_host])
mapping = '''
{
"mappings": {
"article": {
"properties": {
"id": { "type": "text" },
"title": { "type": "text"},
"abstract": { "type": "text"},
"author": {
"properties": {
"id": { "type": "text" },
"name": { "type": "text" }
}
}
}
}
}
}
'''
res = elastic_con.indices.create(index='test-index', ignore=400, body=mapping)
if 'error' in res and res['status'] == 400:
# NOTE: Illegal argument errors are also being masked here, so test the index creation
error_type = res['error']['root_cause'][0]['type']
if error_type == 'resource_already_exists_exception':
logger.debug("Index already exists")
else:
logger.error("Error Occurred in Index creation:{0}".format(res))
print("\n -- Unable to create Index:"+error_type+"--\n")
sys.exit(1)
elif res['acknowledged'] and res['index'] == __index_name__:
logger.debug("Index Created")
else:
logger.error("Index creation failed:{0}".format(res))
print("\n -- Unable to create Index--\n")
sys.exit(1)
Ошибка выглядит следующим образом:
{
"error":
{"root_cause":[{
"type":"mapper_parsing_exception",
"reason":"Root mapping definition has unsupported parameters: [article : {properties={author={properties={name={type=text}, id={type=text}}}, id={type=text}, abstract={type=text}, title={type=text}}}]"}],
"type":"mapper_parsing_exception",
"reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [article : {properties={author={properties={name={type=text}, id={type=text}}}, id={type=text}, abstract={type=text}, title={type=text}}}]",
"caused_by":{"type":"mapper_parsing_exception",
"reason":"Root mapping definition has unsupported parameters: [article : {properties={author={properties={name={type=text}, id={type=text}}}, id={type=text}, abstract={type=text}, title={type=text}}}]"}
},
"status":400
}
Любая помощь будет принята с благодарностью!: D