WoJ
WoJ

Reputation: 29987

Is it possible to force a mapping, server side, on a specific index?

I send to Elasticsearch data to a index mydata. This index may or may not exist when the data reaches Elasticsearch and is automatically created.

The mapping guessed from my data was correct up to now, when I added a new field of geo_point type. This type, as far as I understand, must be explicitly provided with a mapping.

My understanding is that mapping is handled

None of these solutions work for me, the index is deleted / recreated rarely (but unpredictibly) and adding the mapping to each document sent to the server would be too much.

Is there a way to store, on the server, an information of the type "if you create index mydata, the field position must be of type geo_ip"?

Upvotes: 0

Views: 458

Answers (1)

Val
Val

Reputation: 217314

Index templates will do exactly what you need. Simply create a template (with mappings and settings) whose name matches your index name and as soon as a new document comes in for an index that doesn't exist yet, the latter will be automatically create with the proper mappings and settings.

To answer your second question, yes, your mapping may only contain the definition of a few fields (the geo_point you mentioned, etc) and you can let ES map the other ones dynamically.

Upvotes: 1

Related Questions