defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) }; existing_indexes = Model.collection.indexes.map { |i| i['key'].keys }; missing_indexes = defined_indexes - existing_indexes # => [] extra_indexes = existing_indexes - defined_indexes - [['_id']] # => [] ################################################################################# # if the arrays are correct (hopefully the indexes have {background: true} flag), # then you're good to run Model.create_indexes # or Model.remove_indexes