{"record":{"id":"22da3b14c7c5bf22","repo":"mongodb/mongoid","slug":"hnswoptions-is-only-supported-with-indexingmethod","errorCode":null,"errorMessage":"hnswOptions is only supported with indexingMethod: hnsw","messagePattern":"hnswOptions is only supported with indexingMethod: hnsw","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/search_indexable.rb","lineNumber":408,"sourceCode":"        agg_pipeline.concat(Array(pipeline))\n\n        collection.aggregate(agg_pipeline).map { |doc| instantiate(doc) }\n      end\n\n      private\n\n      # Validates the vector index definition, raising ArgumentError for\n      # combinations that MongoDB does not support.\n      #\n      # @param [ Hash ] defn The vector search index definition.\n      def validate_vector_index_definition!(defn)\n        fields = defn[:fields] || defn['fields'] || []\n        fields.each do |field|\n          method = field[:indexingMethod] || field['indexingMethod']\n          next unless method.to_s == 'flat'\n          next unless field[:hnswOptions] || field['hnswOptions']\n\n          raise ArgumentError, 'hnswOptions is only supported with indexingMethod: hnsw'\n        end\n      end\n\n      # Retrieves the index records for the indexes with the given names.\n      #\n      # @param [ Array<String> ] names the index names to query\n      #\n      # @return [ Array<Hash> ] the raw index documents\n      def get_indexes(names)\n        collection.search_indexes.select { |i| names.include?(i['name']) }\n      end\n\n      # Resolves the index name and vector path from the declared specs,\n      # applying inference when either is omitted.\n      #\n      # @param [ String | Symbol | nil ] index The requested index name.\n      # @param [ String | Symbol | nil ] path The requested field path.\n      #","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/search_indexable.rb#L390-L426","documentation":"Error \"hnswOptions is only supported with indexingMethod: hnsw\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/search_indexable.rb:408 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"}