{"record":{"id":"e379aa54f2a57dc8","repo":"dgraph-io/dgraph","slug":"tokenizers-present-without-indexing-on-attr-s","errorCode":null,"errorMessage":"Tokenizers present without indexing on attr %s","messagePattern":"Tokenizers present without indexing on attr (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/parse.go","lineNumber":435,"sourceCode":"\n\t\tif (typ == types.UidID || typ == types.DefaultID || typ == types.PasswordID) &&\n\t\t\tschema.Directive == pb.SchemaUpdate_INDEX {\n\t\t\treturn errors.Errorf(\"Indexing not allowed on predicate %s of type %s\",\n\t\t\t\tx.ParseAttr(schema.Predicate), typ.Name())\n\t\t}\n\n\t\tif typ == types.UidID {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !HasTokenizerOrVectorIndexSpec(schema) &&\n\t\t\tschema.Directive == pb.SchemaUpdate_INDEX {\n\t\t\treturn errors.Errorf(\n\t\t\t\t\"Require type of tokenizer for pred: %s of type: %s for indexing.\",\n\t\t\t\tschema.Predicate, typ.Name())\n\t\t} else if HasTokenizerOrVectorIndexSpec(schema) &&\n\t\t\tschema.Directive != pb.SchemaUpdate_INDEX {\n\t\t\treturn errors.Errorf(\"Tokenizers present without indexing on attr %s\",\n\t\t\t\tx.ParseAttr(schema.Predicate))\n\t\t}\n\t\t// check for valid tokenizer types and duplicates\n\t\tvar seen = make(map[string]bool)\n\t\tvar seenSortableTok bool\n\t\tfor _, t := range schema.Tokenizer {\n\t\t\ttokenizer, has := tok.GetTokenizer(t)\n\t\t\tif !has {\n\t\t\t\treturn errors.Errorf(\"Invalid tokenizer %s\", t)\n\t\t\t}\n\t\t\ttokenizerType, ok := types.TypeForName(tokenizer.Type())\n\t\t\tx.AssertTrue(ok) // Type is validated during tokenizer loading.\n\t\t\tif tokenizerType != typ {\n\t\t\t\treturn errors.Errorf(\"Tokenizer: %s isn't valid for predicate: %s of type: %s\",\n\t\t\t\t\ttokenizer.Name(), x.ParseAttr(schema.Predicate), typ.Name())\n\t\t\t}\n\t\t\tif _, ok := seen[tokenizer.Name()]; !ok {\n\t\t\t\tseen[tokenizer.Name()] = true","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/schema/parse.go#L417-L453","documentation":"The inverse of the previous case: the schema update declares tokenizers (or a vector index spec) for a predicate but the directive is not @index. Tokenizers only make sense with an index, so resolveTokenizers rejects the update, naming the attribute. This keeps the stored schema internally consistent.","triggerScenarios":"Altering schema with `pred: string @hash .` (tokenizer given without @index) or a SchemaUpdate with a non-INDEX directive but populated Tokenizer list / vector spec.","commonSituations":"Typos like writing `@index` wrong or omitting it while listing tokenizers; editing schema by hand and dropping the @index keyword; tooling that sets Tokenizer but forgets Directive; converting a previously indexed predicate back to non-indexed while leaving old tokenizers.","solutions":["Add the @index directive: `pred: string @index(hash) .`","Or remove the tokenizer list if the predicate should not be indexed: `pred: string .`","Check any schema-generation tooling to ensure Directive=SchemaUpdate_INDEX is set whenever Tokenizer is non-empty.","Re-apply the alteration."],"exampleFix":"// before\nname: string @hash .\n// after\nname: string @index(hash) .","handlingStrategy":"validation","validationCode":"function requireIndexWithTokenizers(line) {\n  const hasTok = /@(hash|exact|term|fulltext|trigram|int|float|datetime|geo|default)\\b/.test(line);\n  const hasIndex = /@index\\s*\\(/.test(line);\n  if (hasTok && !hasIndex) throw new Error('tokenizers present without @index: ' + line);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await dgraph.Alter(ctx, op);\n} catch (e) {\n  if (String(e).includes('Tokenizers present without indexing')) {\n    // either add @index(...) or drop the tokenizers, then retry\n  }\n  throw e;\n}","preventionTips":["Write directives as @index(tokenizer, ...), never bare @hash/@term","When unindexing a predicate, also clear its Tokenizer list","Ensure programmatic clients set Directive=INDEX whenever Tokenizer is non-empty"],"tags":["dgraph","schema","indexing","tokenizer"],"backgroundTag":"schema-validation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}