I'm trying to create an index in Elasticsearch through Python. I have a local instance of ES deployed and queries run fine. However, I have a schema. Here it is:
{
"mappings": {
"payment":{
"properties":{
"timestamp":{"type":"date"},
"base_amount":{"type":"integer"},
"derived_id":{"type":"keyword", "fielddata": true},
"attempts":{"type":"integer"},
"status":{"type":"text","fielddata":true},
"error_code":{"type":"text","fielddata":true}
}
}
}
}
Here is the code I am using to create this index
import json
import requests
schema = {
"mappings": {
"payment": {
"properties": {
"timestamp": {"type": "date"},
"base_amount": {"type": "integer"},
"derived_key": {"type": "keyword", "fielddata": True},
"attempts": {"type": "integer"},
"status": {"type": "text", "fielddata": True},
"error_code": {"type": "text", "fielddata": True}
}
}
}
}
index = 'http://localhost:9200/payment_index_2016_08_21'
r = requests.put(index, data=json.dumps(schema))
print r.content
The error I get is
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [payment]: Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]"}},"status":400}
I don't understand why the fielddata = true
is causing an issue, since I see it's allowed here https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html. Any clue what the issue behind this is?
You don't need to enable fielddata
on keyword fields. you can do aggregations on keyword fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With