mongodb/mongoid · error · ArgumentError

No vector search index '#

Error message

No vector search index '#{index}' declared on #{name}

What it means

Raised by SearchIndexable#resolve_vector_index when a specific vector search index name was requested via index: but no declared spec on the model matches that name. The faulting input is the index name string not present among the model's vectorSearch specs.

Solutions

  1. Check the index name spelling against the declared vector_search_index specs
  2. Declare the index with the requested name via vector_search_index name: '...'
  3. Omit index: to let Mongoid infer when only one index exists
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/mongoid/search_indexable.rb:435 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/3aea36da82e43939. Report an issue: GitHub.

Appendix: source

Thrown at lib/mongoid/search_indexable.rb:435

      def get_indexes(names)
        collection.search_indexes.select { |i| names.include?(i['name']) }
      end

      # Resolves the index name and vector path from the declared specs,
      # 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_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'.
      #

View on GitHub (pinned to 0da0e23d71)