inveniosoftware / domapping

Package generating elasticsearch mapping from jsonschemas
https://domapping.readthedocs.io
GNU General Public License v2.0
14 stars 8 forks source link

How to use with ElasticSearch? #28

Open leplatrem opened 7 years ago

leplatrem commented 7 years ago

I have been trying to use it with ElasticSearch this way:

mapping = schema_to_mapping(json_schema, root_url, {}, ElasticMappingGeneratorConfig())
mappings = {indexname: mapping}
client = elasticsearch.Elasticsearch(hosts)
client.indices.create(index=indexname,
                      body={"mappings": mappings})

...but got the following error:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [_all] has unsupported parameters:  [enable : true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [kinto-bid-cid]: Mapping definition for [_all] has unsupported parameters:  [enable : true]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping definition for [_all] has unsupported parameters:  [enable : true]"}},"status":400}

I could get it to work by stripping out some part of the result of schema_to_mapping:

mapping = schema_to_mapping(json_schema, root_url, {}, ElasticMappingGeneratorConfig())
mapping = {"properties": mapping["properties"]}

Am I doing something wrong? Is this expected?

Thanks for the tool :)