{"record":{"id":"351f4df5bc1b4314","repo":"mongodb/mongoid","slug":"name-has-multiple-auto-embed-indexes-specify-i","errorCode":null,"errorMessage":"#{name} has multiple auto-embed indexes; specify index: to select one","messagePattern":"#(.+?) has multiple auto-embed indexes; specify index: to select one","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/search_indexable.rb","lineNumber":508,"sourceCode":"        [ resolved_index, resolved_path ]\n      end\n\n      # Picks one spec from the list of auto-embed specs, guided by +index+.\n      #\n      # @param [ Array<Hash> ] specs The candidate auto-embed specs.\n      # @param [ String | Symbol | nil ] index The requested index name.\n      #\n      # @return [ Hash ] the selected spec.\n      def select_auto_embed_spec(specs, index)\n        if index\n          found = specs.find { |s| s[:name] == index.to_s }\n          raise ArgumentError, \"No auto-embed index '#{index}' declared on #{name}\" unless found\n\n          found\n        elsif specs.size == 1\n          specs.first\n        else\n          raise ArgumentError,\n                \"#{name} has multiple auto-embed indexes; specify index: to select one\"\n        end\n      end\n\n      # Infers the text field path from an index definition by locating\n      # the first field declared with type 'autoEmbed'.\n      #\n      # @param [ Hash ] spec The vector search index spec.\n      #\n      # @return [ String ] the field path.\n      def infer_auto_embed_path(spec)\n        field_list = spec.dig(:definition, :fields) || spec.dig(:definition, 'fields') || []\n        ae_field   = field_list.find { |f| (f[:type] || f['type']) == 'autoEmbed' }\n\n        unless ae_field\n          raise ArgumentError,\n                \"Cannot infer path on #{name}: no 'autoEmbed' field in index definition; specify path:\"\n        end","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/search_indexable.rb#L490-L526","documentation":"Error \"#{name} has multiple auto-embed indexes; specify index: to select one\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/search_indexable.rb:508 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}