{"record":{"id":"89828647fd637699","repo":"dgraph-io/dgraph","slug":"unknown-option-in-similar-to-q","errorCode":null,"errorMessage":"Unknown option in similar_to: %q","messagePattern":"Unknown option in similar_to: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/task.go","lineNumber":2818,"sourceCode":"\t\t\tif perr != nil {\n\t\t\t\treturn errors.Errorf(\"Invalid value for 'ef' in similar_to: %q\", v)\n\t\t\t}\n\t\t\tif n <= 0 {\n\t\t\t\treturn errors.Errorf(\"Value for 'ef' must be positive, got: %d\", n)\n\t\t\t}\n\t\t\tfc.vsEfOverride = int(n)\n\t\tcase \"distance_threshold\":\n\t\t\tf, perr := strconv.ParseFloat(v, 64)\n\t\t\tif perr != nil {\n\t\t\t\treturn errors.Errorf(\"Invalid value for 'distance_threshold' in similar_to: %q\", v)\n\t\t\t}\n\t\t\tif f < 0 {\n\t\t\t\treturn errors.Errorf(\"Value for 'distance_threshold' must be non-negative, got: %v\", f)\n\t\t\t}\n\t\t\tfc.vsDistanceThreshold = new(float64)\n\t\t\t*fc.vsDistanceThreshold = f\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"Unknown option in similar_to: %q\", k)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":2800,"sourceCodeEnd":2823,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/task.go#L2800-L2823","documentation":"The similar_to option parser accepts only the keys 'ef' and 'distance_threshold'. Any other key reaches the default branch of the switch and produces this error, naming the offending key. This prevents silently ignoring misspelled options.","triggerScenarios":"similar_to option string with a typo'd or unsupported key: 'similar_to: \"vec; efs: 100\"', 'ef-s: 10', 'k: 5', or capitalization variants if any slip through. The key is matched after trimming trailing colons, so 'ef:' keys still match, but 'EF' style variants would not if case differs.","commonSituations":"Typos like 'ef_s' or 'distanceThreshhold'; copying options from a different search engine's syntax (e.g. 'k:' from kNN APIs); older query syntax that used a since-removed option name after a version upgrade.","solutions":["Use only supported keys: 'ef' and 'distance_threshold'.","Fix the typo in the option key in the failing query.","Check the Dgraph version's documented similar_to options if migrating from another version."],"exampleFix":"// before\n\"vec; ef_s: 100\"\n// after\n\"vec; ef: 100\"","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"ef\": true, \"distance_threshold\": true}\nfor k := range myOptions {\n    if !allowed[k] { return fmt.Errorf(\"unsupported similar_to option: %s\", k) }\n}","typeGuard":null,"tryCatchPattern":"if err := runQuery(ctx); err != nil && strings.Contains(err.Error(), \"Unknown option in similar_to\") {\n    return fmt.Errorf(\"check similar_to keys (only ef, distance_threshold allowed): %w\", err)\n}","preventionTips":["Keep a whitelist of supported similar_to keys in your query builder.","Check the Dgraph docs for the current option set when upgrading versions.","Avoid copying option syntax from other vector search engines."],"tags":["dql","query-options","parsing","typo"],"backgroundTag":"unknown-option-key","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}