Reputation: 29
In my project we have a feature that creates dynamic fields to the object so the field type can be for example text, float, object. and the user can change type for example I have a number field so the mapping in elastic will be float, and I changed the value to text it will cause an error in mapping.
or for example it was object then string, long story short mapping will cause issues, and if I ignored the mappings I will lose the ability to filter on these fields.
Is there a way in elastic that I can ignore the mapping and use filter?
Upvotes: 0
Views: 365
Reputation: 1310
Elasticsearch doesn't support change in type of fields. It is really important to define your Schema carefully, it is still possible to change the field type but you would need to reindex
your data again. For more information about Reindex API
you can check the ES official documentation here.
You can also try to implement your field mapping with suffix so each type of your field would have its own field. For example if you have a field name User
and your client specified it as long
you can store it as user_long
and map it as long
and if the client change the type later on in the application to string
you can create new field user_text
and map it as a text. Keep in mind with this approach you might need to convert your data but you won't need reindexing
.
Upvotes: 0