{"record":{"id":"ea1551fae8958ddf","repo":"redis/go-redis","slug":"ft-create-on-hash-and-on-json-are-mutually-exclus","errorCode":null,"errorMessage":"FT.CREATE: ON HASH and ON JSON are mutually exclusive","messagePattern":"FT\\.CREATE: ON HASH and ON JSON are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":1395,"sourceCode":"// FTCreate - Creates a new index with the given options and schema.\n// The 'index' parameter specifies the name of the index to create.\n// The 'options' parameter specifies various options for the index, such as:\n// whether to index hashes or JSONs, prefixes, filters, default language, score, score field, payload field, etc.\n// The 'schema' parameter specifies the schema for the index, which includes the field name, field type, etc.\n// For more information, please refer to the Redis documentation:\n// [FT.CREATE]: (https://redis.io/commands/ft.create/)\nfunc (c cmdable) FTCreate(ctx context.Context, index string, options *FTCreateOptions, schema ...*FieldSchema) *StatusCmd {\n\targs := []interface{}{\"FT.CREATE\", index}\n\tif options != nil {\n\t\tif options.OnHash && !options.OnJSON {\n\t\t\targs = append(args, \"ON\", \"HASH\")\n\t\t}\n\t\tif options.OnJSON && !options.OnHash {\n\t\t\targs = append(args, \"ON\", \"JSON\")\n\t\t}\n\t\tif options.OnHash && options.OnJSON {\n\t\t\tcmd := NewStatusCmd(ctx, args...)\n\t\t\tcmd.SetErr(fmt.Errorf(\"FT.CREATE: ON HASH and ON JSON are mutually exclusive\"))\n\t\t\treturn cmd\n\t\t}\n\t\tif options.Prefix != nil {\n\t\t\targs = append(args, \"PREFIX\", len(options.Prefix))\n\t\t\targs = append(args, options.Prefix...)\n\t\t}\n\t\tif options.Filter != \"\" {\n\t\t\targs = append(args, \"FILTER\", options.Filter)\n\t\t}\n\t\tif options.DefaultLanguage != \"\" {\n\t\t\targs = append(args, \"LANGUAGE\", options.DefaultLanguage)\n\t\t}\n\t\tif options.LanguageField != \"\" {\n\t\t\targs = append(args, \"LANGUAGE_FIELD\", options.LanguageField)\n\t\t}\n\t\tif options.Score > 0 {\n\t\t\targs = append(args, \"SCORE\", options.Score)\n\t\t}","sourceCodeStart":1377,"sourceCodeEnd":1413,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/search_commands.go#L1377-L1413","documentation":"Error \"FT.CREATE: ON HASH and ON JSON are mutually exclusive\" thrown in redis/go-redis.","triggerScenarios":"Thrown at search_commands.go:1395 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":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}