My question is about changing a field type in my elasticsearch index using the elasticsearch ruby client chewy.
I am trying to update a field type in my index. I am getting this error: illegal_argument_exception
.
I have read that it is impossible to change type in an existing index, so I was thinking about reindexing everything: rake chewy:reset
. I have tried many things... I can't get my reindexation working.
The detailed error:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [enabled] cannot be changed from type [text] to [boolean]"}],"type":"illegal_argument_exception","reason":"mapper [enabled] cannot be changed from type [text] to [boolean]"},"status":400}
My index as it was before (field enabled was a texte, by default):
class SearchIndex < Chewy::Index
define_type Company, delete_if: :deleted_at do
...
field :enabled
...
end
end
My index as I want it to be:
class SearchIndex < Chewy::Index
define_type Company, delete_if: :deleted_at do
...
field :enabled, type: 'boolean'
...
end
end
How can I do with Chewy (without requesting to ElasticSearch via curl, if possible) to get my index reindexed with the new field type ?
Thanks.