mongodb/mongoid · error · ArgumentError
#{resolved_path} is nil on this document; cannot perform vec
Error message
#{resolved_path} is nil on this document; cannot perform vector search What it means
Error "#{resolved_path} is nil on this document; cannot perform vector search" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/search_indexable.rb:87
# @param [ Integer ] limit The maximum number of results (default: 10).
# @param [ Integer | nil ] num_candidates The number of candidates to
# consider during the ANN search; defaults to limit * 10.
# @param [ true | false ] exact Use exact nearest-neighbor (ENN) search
# instead of ANN (default: false). When true, numCandidates is omitted.
# Required when using a flat vector search index.
# @param [ Hash | nil ] filter An optional MongoDB filter to pre-filter
# candidates before scoring.
# @param [ Array ] pipeline Additional aggregation stages to append after
# the vector search and score projection.
#
# @return [ Array<Mongoid::Document> ] matching documents, each with
# a populated +vector_search_score+ attribute.
def vector_search(index: nil, path: nil, limit: 10, num_candidates: nil, exact: false, filter: nil, pipeline: []) # rubocop:disable Metrics/ParameterLists
_index, resolved_path = self.class.send(:resolve_vector_index, index, path)
query_vector = public_send(resolved_path)
if query_vector.nil?
raise ArgumentError,
"#{resolved_path} is nil on this document; cannot perform vector search"
end
self_exclusion = { '$match' => { '_id' => { '$ne' => _id } } }
post_pipeline = [ self_exclusion, { '$limit' => limit }, *Array(pipeline) ]
effective_candidates = num_candidates || (limit * 10)
self.class.vector_search(
query_vector,
index: index,
path: path,
limit: limit + 1,
num_candidates: effective_candidates,
exact: exact,
filter: filter,
pipeline: post_pipeline
)
endView on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/search_indexable.rb:87 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/16a17992da4161e7.
Report an issue: GitHub.