mongodb/mongoid · error · ArgumentError

No auto-embed indexes declared on #{name}

Error message

No auto-embed indexes declared on #{name}

What it means

Error "No auto-embed indexes declared on #{name}" thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/search_indexable.rb:483

        (vector_field[:path] || vector_field['path']).to_s
      end

      # Resolves the index name and text field path for an auto-embedding
      # query, applying inference when either is omitted.
      #
      # @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_auto_embed_index(index, path)
        auto_embed_specs = search_index_specs.select do |s|
          s[:type] == 'vectorSearch' &&
            (s.dig(:definition, :fields) || s.dig(:definition, 'fields') || [])
              .any? { |f| (f[:type] || f['type']) == 'autoEmbed' }
        end

        raise ArgumentError, "No auto-embed indexes declared on #{name}" if auto_embed_specs.empty?

        # Extracted to keep cyclomatic complexity within RuboCop's threshold.
        spec = select_auto_embed_spec(auto_embed_specs, index)
        resolved_index = spec[:name] || 'default'
        resolved_path  = path ? path.to_s : infer_auto_embed_path(spec)

        [ 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 }

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/search_indexable.rb:483 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/0f48c9420af120b5. Report an issue: GitHub.