Method: Mongoid::Tasks::Database#create_search_indexes
- Defined in:
- lib/mongoid/tasks/database.rb
#create_search_indexes(models = ::Mongoid.models, wait: true) ⇒ Object
Submit requests for the search indexes to be created. This will happen asynchronously. If “wait” is true, the method will block while it waits for the indexes to be created.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mongoid/tasks/database.rb', line 67 def create_search_indexes(models = ::Mongoid.models, wait: true) searchable = models.select { |m| m.search_index_specs.any? } # queue up the search index creation requests index_names_by_model = searchable.each_with_object({}) do |model, obj| logger.info("MONGOID: Creating search indexes on #{model}...") obj[model] = model.create_search_indexes end wait_for_search_indexes(index_names_by_model) if wait end |