Where do I put the mapping files for Elasticsearch? Where do I put the mapping files for Elasticsearch? json json

Where do I put the mapping files for Elasticsearch?


There is a difference between mappings and templates.

Mappings contain your fields and how you want to index/store them in elasticsearch. They refer to a specific index and type (or multiple types in the same index when using the _default_ special type). You can submit mappings either while creating an index through the create index api, or through the put mapping api to modify the mappings for an existing index.

Index templates are a way to automatically apply mappings and index settings to indices that are going to be created in the future, whose names match a specified pattern. Let's say that mappings are a part of an index template. An index template can contains mappings for multiple types and index settings too.

If you have an index template, you can put it under templates as mentioned in the reference. If you have a mapping for a type, you need to put it under the mappings directory.

The json that you pasted into the question is an index template, which needs to go under the templates folder, not under the mappings one. What you get back using the get mapping api as described is not the template itself as you said but the current mapping for the index/type that you specified in the url (only the mappings part of your template).

Also, I would suggest you to use the REST api that elasticsearch provides. Using files on file system doesn't really look like the elasticsearch way of doing things.