{"record":{"id":"6d6dfbb5f8d67196","repo":"litedb-org/LiteDB","slug":"field","errorCode":null,"errorMessage":"field","messagePattern":"field","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"LiteDB/Client/Database/LiteQueryable.cs","lineNumber":280,"sourceCode":"            return this.VectorWhereNear(fieldExpr, target, maxDistance);\n        }\n\n        internal ILiteQueryable<T> VectorWhereNear(BsonExpression fieldExpr, float[] target, double maxDistance)\n        {\n            var filter = CreateVectorSimilarityFilter(fieldExpr, target, maxDistance);\n\n            _query.Where.Add(filter);\n\n            _query.VectorField = fieldExpr.Source;\n            _query.VectorTarget = target?.ToArray();\n            _query.VectorMaxDistance = maxDistance;\n\n            return this;\n        }\n\n        internal ILiteQueryable<T> VectorWhereNear<K>(Expression<Func<T, K>> field, float[] target, double maxDistance)\n        {\n            if (field == null) throw new ArgumentNullException(nameof(field));\n\n            var fieldExpr = _mapper.GetExpression(field);\n            return this.VectorWhereNear(fieldExpr, target, maxDistance);\n        }\n\n        internal ILiteQueryableResult<T> VectorTopKNear<K>(Expression<Func<T, K>> field, float[] target, int k)\n        {\n            var fieldExpr = _mapper.GetExpression(field);\n            return this.VectorTopKNear(fieldExpr, target, k);\n        }\n\n        internal ILiteQueryableResult<T> VectorTopKNear(string field, float[] target, int k)\n        {\n            var fieldExpr = BsonExpression.Create($\"$.{field}\");\n            return this.VectorTopKNear(fieldExpr, target, k);\n        }\n\n        internal ILiteQueryableResult<T> VectorTopKNear(BsonExpression fieldExpr, float[] target, int k)","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Client/Database/LiteQueryable.cs#L262-L298","documentation":"Thrown by VectorWhereNear<K>(Expression<Func<T, K>> field, ...) when the field selector expression is null. This overload resolves the LINQ expression to a BsonExpression via the mapper; a null expression cannot be translated. Reached when callers pass a strongly-typed member selector.","triggerScenarios":"Calling VectorWhereNear<ICollection<float>>(null, vec, dist), or passing an expression variable that was conditionally assigned null.","commonSituations":"Building the selector dynamically and a branch leaves it null, or refactoring from a string field name to a LINQ selector and forgetting to supply it.","solutions":["Pass a real member selector, e.g. x => x.Embedding.","Null-check the expression before calling if it is built dynamically.","If the field name is only known at runtime, use the string overload instead."],"exampleFix":"// before\nvar q = col.Query().VectorWhereNear(selectorExpr, vec, dist);\n\n// after\nif (selectorExpr == null)\n    throw new InvalidOperationException(\"Vector field selector is required.\");\nvar q = col.Query().VectorWhereNear(selectorExpr, vec, dist);","handlingStrategy":"validation","validationCode":"if (field == null)\n    throw new ArgumentException(\"A field selector expression is required.\", nameof(field));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass concrete lambdas like x => x.Embedding.","Fall back to the string overload when the field name is only known at runtime."],"tags":["vector","vector-search","argument-null","linq"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}