inveniosoftware / domapping

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

Incorrect property name ('settings' instead of 'mappings') #9

Closed switowski closed 8 years ago

switowski commented 8 years ago

As reported by @JavierDelgadoFernandez, domapping is putting ElasticSearch mappings under settings key in the generated file, while they should go inside mappings key.

nharraud commented 8 years ago

Is there an explicit "settings" key generated? Normally DoMapping generates the content of the type mapping corresponding to the given JSON Schema. The idea is that it can also be used manually like this:

PUT myindex/_mapping/mydoctype 
{
  "properties": {
    "name": {
      "type": "string"
    }
  }
}

If DoMapping was adding enclosing "mappings" or "settings" it could not be used like that anymore. There is also the issue that DoMapping cannot know how you want to name the doctype.

In order to set all the mappings in one request, the recommended solution is to use a jinja template including all the type mappings into one global index "mappings" file. This is more extensible as you might want to add later other doctypes to the mappings.

nharraud commented 8 years ago

After some discussion with @JavierDelgadoFernandez, it would be possible to add some options to the CLI when generating the mapping from the JSON Schema. These options would add enclosing document type and mappings dictionaries. The one adding the document type should take the document type name as argument.

This will be useful for cases when multiple indexes with only one document type are created. Analysis preservation is one of these use cases.