{"record":{"id":"16a17992da4161e7","repo":"mongodb/mongoid","slug":"resolved-path-is-nil-on-this-document-cannot-p","errorCode":null,"errorMessage":"#{resolved_path} is nil on this document; cannot perform vector search","messagePattern":"#(.+?) is nil on this document; cannot perform vector search","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/search_indexable.rb","lineNumber":87,"sourceCode":"    # @param [ Integer ] limit The maximum number of results (default: 10).\n    # @param [ Integer | nil ] num_candidates The number of candidates to\n    #   consider during the ANN search; defaults to limit * 10.\n    # @param [ true | false ] exact Use exact nearest-neighbor (ENN) search\n    #   instead of ANN (default: false). When true, numCandidates is omitted.\n    #   Required when using a flat vector search index.\n    # @param [ Hash | nil ] filter An optional MongoDB filter to pre-filter\n    #   candidates before scoring.\n    # @param [ Array ] pipeline Additional aggregation stages to append after\n    #   the vector search and score projection.\n    #\n    # @return [ Array<Mongoid::Document> ] matching documents, each with\n    #   a populated +vector_search_score+ attribute.\n    def vector_search(index: nil, path: nil, limit: 10, num_candidates: nil, exact: false, filter: nil, pipeline: []) # rubocop:disable Metrics/ParameterLists\n      _index, resolved_path = self.class.send(:resolve_vector_index, index, path)\n      query_vector = public_send(resolved_path)\n\n      if query_vector.nil?\n        raise ArgumentError,\n              \"#{resolved_path} is nil on this document; cannot perform vector search\"\n      end\n\n      self_exclusion = { '$match' => { '_id' => { '$ne' => _id } } }\n      post_pipeline = [ self_exclusion, { '$limit' => limit }, *Array(pipeline) ]\n      effective_candidates = num_candidates || (limit * 10)\n\n      self.class.vector_search(\n        query_vector,\n        index: index,\n        path: path,\n        limit: limit + 1,\n        num_candidates: effective_candidates,\n        exact: exact,\n        filter: filter,\n        pipeline: post_pipeline\n      )\n    end","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/search_indexable.rb#L69-L105","documentation":"Error \"#{resolved_path} is nil on this document; cannot perform vector search\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/search_indexable.rb:87 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"}