You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a given model in our app, we use custom mappings with dynamic: 'strict' and have a custom search_data method that return the data to be indexed in the right schema.
In some situations, we want to just add a couple of attributes to the schema, and it is not needed to create a new index to replace the old one like reindex do. Instead, we'd like to just update the schema for the existing index, and the searches for the attributes previously available will keep working until we re-index the whole table to have the new ones (and in our app, this means many many hours).
I managed to implement a simple method to do that, but I believe this could be available and documented on Searchkick itself.
classModel < ApplicationRecorddefself.update_index_mappings!index_name=Model.searchkick_index.namemappings=Model.searchkick_index.options[:mappings]json=Oj.dump(mappings)Rails.logger.info("Updating index mappings for #{index_name}: #{json.inspect}")Excon.put("#{ENV['OPENSEARCH_URL']}/#{index_name}/_mapping",headers: {'Content-Type'=>'application/json'},body: Oj.dump(mappings))endend
The text was updated successfully, but these errors were encountered:
Hi there,
For a given model in our app, we use custom
mappings
withdynamic: 'strict'
and have a customsearch_data
method that return the data to be indexed in the right schema.In some situations, we want to just add a couple of attributes to the schema, and it is not needed to create a new index to replace the old one like
reindex
do. Instead, we'd like to just update the schema for the existing index, and the searches for the attributes previously available will keep working until we re-index the whole table to have the new ones (and in our app, this means many many hours).I managed to implement a simple method to do that, but I believe this could be available and documented on Searchkick itself.
The text was updated successfully, but these errors were encountered: