I am new to elasticsearch and want to use the official Python API. I have below code:
from elasticsearch import Elasticsearch
es = Elasticsearch(timeout=60)
es.indices.create(index='test')
mapping={
"mappings": {
"user": {
"properties": {
"name": { "type": "text" },
"user_name": { "type": "keyword" },
"email": { "type": "keyword" }
}
},
"tweet": {
"properties": {
"content": { "type": "text" },
"user_name": { "type": "keyword" },
"tweeted_at": { "type": "date" }
}
}
}
}
es.indices.put_mapping(index='test',body=mapping)
However I got below error:
RequestError: RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters: [mappings : {tweet={properties={tweeted_at={type=date}, user_name={type=keyword}, content={type=text}}}, user={properties={user_name={type=keyword}, name={type=text}, email={type=keyword}}}}]')
This mapping is copied from:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
Could anyone help figure out what was wrong here?
Many thanks