mongodb/mongoid · error · ArgumentError

Cannot infer path on #{name}: no 'autoEmbed' field in index

Error message

Cannot infer path on #{name}: no 'autoEmbed' field in index definition; specify path:

What it means

Error "Cannot infer path on #{name}: no 'autoEmbed' field in index definition; specify path:" thrown in mongodb/mongoid.

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)

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.