mongodb/mongoid · error · ArgumentError
Cannot infer path on #
Error message
Cannot infer path on #{name}: no 'autoEmbed' field in index definition; specify path: What it means
Raised by SearchIndexable#infer_auto_embed_path when the selected index definition has no field of type 'autoEmbed', so the text field path cannot be inferred and path: was not given. The faulting input is an index spec lacking an autoEmbed-typed field.
Solutions
- Pass path: explicitly to auto_embed_search
- Declare a field with type: 'autoEmbed' in the index definition
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at lib/mongoid/search_indexable.rb:524 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/a5e6e4f66f9feff5.
Report an issue: GitHub.
Appendix: source
Thrown at lib/mongoid/search_indexable.rb:524
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:"
end
(ae_field[:path] || ae_field['path']).to_s
end
end
end
end
View on GitHub (pinned to 0da0e23d71)