mongodb/mongoid · error · ArgumentError
#{name} has multiple auto-embed indexes; specify index: to s
Error message
#{name} has multiple auto-embed indexes; specify index: to select one What it means
Error "#{name} has multiple auto-embed indexes; specify index: to select one" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/search_indexable.rb:508
[ resolved_index, resolved_path ]
end
# Picks one spec from the list of auto-embed specs, guided by +index+.
#
# @param [ Array<Hash> ] specs The candidate auto-embed specs.
# @param [ String | Symbol | nil ] index The requested index name.
#
# @return [ Hash ] the selected spec.
def select_auto_embed_spec(specs, index)
if index
found = specs.find { |s| s[:name] == index.to_s }
raise ArgumentError, "No auto-embed index '#{index}' declared on #{name}" unless found
found
elsif specs.size == 1
specs.first
else
raise ArgumentError,
"#{name} has multiple auto-embed indexes; specify index: to select one"
end
end
# Infers the text field path from an index definition by locating
# the first field declared with type 'autoEmbed'.
#
# @param [ Hash ] spec The vector search index spec.
#
# @return [ String ] the field path.
def infer_auto_embed_path(spec)
field_list = spec.dig(:definition, :fields) || spec.dig(:definition, 'fields') || []
ae_field = field_list.find { |f| (f[:type] || f['type']) == 'autoEmbed' }
unless ae_field
raise ArgumentError,
"Cannot infer path on #{name}: no 'autoEmbed' field in index definition; specify path:"
endView on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/search_indexable.rb:508 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/351f4df5bc1b4314.
Report an issue: GitHub.