mongodb/mongoid · error · ArgumentError
#{name} has multiple vector search indexes; specify index: t
Error message
#{name} has multiple vector search indexes; specify index: to select one What it means
Error "#{name} has multiple vector search indexes; specify index: to select one" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/search_indexable.rb:441
#
# @param [ String | Symbol | nil ] index The requested index name.
# @param [ String | Symbol | nil ] path The requested field path.
#
# @return [ Array<String> ] the resolved [ index_name, field_path ] pair.
def resolve_vector_index(index, path)
vector_specs = search_index_specs.select { |s| s[:type] == 'vectorSearch' }
raise ArgumentError, "No vector search indexes declared on #{name}" if vector_specs.empty?
spec = if index
found = vector_specs.find { |s| s[:name] == index.to_s }
raise ArgumentError, "No vector search index '#{index}' declared on #{name}" unless found
found
elsif vector_specs.size == 1
vector_specs.first
else
raise ArgumentError,
"#{name} has multiple vector search indexes; specify index: to select one"
end
resolved_index = spec[:name] || 'default'
resolved_path = path ? path.to_s : infer_vector_path(spec)
[ resolved_index, resolved_path ]
end
# Infers the vector field path from the index definition by locating
# the first field declared with type 'vector'.
#
# @param [ Hash ] spec The vector search index spec.
#
# @return [ String ] the field path.
def infer_vector_path(spec)
field_list = spec.dig(:definition, :fields) || spec.dig(:definition, 'fields') || []
vector_field = field_list.find { |f| (f[:type] || f['type']) == 'vector' }View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/search_indexable.rb:441 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/1d8958a6ad325d47.
Report an issue: GitHub.