{"record":{"id":"a0cd1771e14f9b5c","repo":"weaviate/weaviate","slug":"nearimu-cannot-provide-both-distance-and-certainty","errorCode":null,"errorMessage":"nearIMU cannot provide both distance and certainty","messagePattern":"nearIMU cannot provide both distance and certainty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/modulecomponents/arguments/nearImu/param.go","lineNumber":53,"sourceCode":"\treturn n.Certainty != 0 || n.WithDistance\n}\n\nfunc (n NearIMUParams) GetTargetVectors() []string {\n\treturn n.TargetVectors\n}\n\nfunc validateNearIMUFn(param interface{}) error {\n\tnearIMU, ok := param.(*NearIMUParams)\n\tif !ok {\n\t\treturn errors.New(\"'nearIMU' invalid parameter\")\n\t}\n\n\tif len(nearIMU.IMU) == 0 {\n\t\treturn errors.New(\"'nearIMU.imu' needs to be defined\")\n\t}\n\n\tif nearIMU.Certainty != 0 && nearIMU.WithDistance {\n\t\treturn errors.New(\n\t\t\t\"nearIMU cannot provide both distance and certainty\")\n\t}\n\n\tif len(nearIMU.TargetVectors) > 1 {\n\t\treturn errors.New(\n\t\t\t\"nearIMU.targetVectors cannot provide more than 1 target vector value\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":35,"sourceCodeEnd":64,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/modulecomponents/arguments/nearImu/param.go#L35-L64","documentation":"nearIMU, like all near* clauses, permits either certainty or distance as the relevance bound but not both. validateNearIMUFn returns this error when Certainty is non-zero while WithDistance is true. The two settings would contradict each other in threshold computation, so the request is rejected.","triggerScenarios":"A nearIMU clause specifying both certainty (e.g. 0.75) and distance (which sets WithDistance) — detected by nearIMU.Certainty != 0 && nearIMU.WithDistance.","commonSituations":"Query templates merging certainty and distance semantics; migration from distance-based to certainty-based searches leaving stale fields; automated clients always emitting both optional params.","solutions":["Keep only one of certainty or distance in the nearIMU clause","Set the other field explicitly to zero/omitted in your query builder","If you need layered thresholds, do one in-query and one post-filter client-side"],"exampleFix":"// before\nnearIMU: { imu: \"...\", certainty: 0.75, distance: 0.2 }\n// after\nnearIMU: { imu: \"...\", distance: 0.2 }","handlingStrategy":"validation","validationCode":"if (args.nearIMU?.certainty != null && args.nearIMU?.distance != null) {\n  throw new Error(\"nearIMU: provide certainty or distance, not both\");\n}","typeGuard":"function hasExactlyOneBound(clause) {\n  return [\"certainty\", \"distance\"].filter(k => clause[k] != null).length === 1;\n}","tryCatchPattern":null,"preventionTips":["Enforce XOR of certainty/distance in the query builder","Remove legacy bound fields during parameter migrations","Document the either-or contract for near* clauses in client SDKs"],"tags":["graphql","validation","nearimu","conflicting-parameters","weaviate"],"backgroundTag":"conflicting-parameters","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}