{"record":{"id":"4c50189d7818cdd8","repo":"dgraph-io/dgraph","slug":"error-creating-indexer-for-s-w","errorCode":null,"errorMessage":"error creating indexer for %s: %w","messagePattern":"error creating indexer for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/bulk/vector_indexer.go","lineNumber":221,"sourceCode":"\tif indexer, ok := vi.indexers[pred]; ok {\n\t\treturn indexer, vi.txnCaches[pred], nil\n\t}\n\n\t// Check if this predicate has a vector index spec\n\tspec, ok := vi.indexSpecs[pred]\n\tif !ok {\n\t\treturn nil, nil, fmt.Errorf(\"no vector index spec for predicate %s\", pred)\n\t}\n\n\t// Create the HNSW indexer\n\tfactorySpec, err := tok.GetFactoryCreateSpecFromSpec(spec)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error getting factory spec for %s: %w\", pred, err)\n\t}\n\n\tindexer, err := factorySpec.CreateIndex(pred)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error creating indexer for %s: %w\", pred, err)\n\t}\n\n\t// Create transaction cache\n\ttxn := posting.NewTxn(vi.state.writeTs)\n\tviTxn := posting.NewViTxn(txn)\n\ttc := hnsw.NewTxnCache(viTxn, vi.state.writeTs)\n\n\tvi.indexers[pred] = indexer\n\tvi.txnCaches[pred] = tc\n\tvi.txns[pred] = txn\n\tvi.vectorPreds[pred] = true\n\n\tglog.Infof(\"Lazily initialized HNSW indexer for predicate %s (shard %d)\", pred, vi.shardId)\n\n\treturn indexer, tc, nil\n}\n\n// isVectorPredicate returns true if the given predicate has a vector index.","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/bulk/vector_indexer.go#L203-L239","documentation":"During bulk vector indexing, getOrCreateIndexer asks the vector index factory to create an indexer for a predicate. If factorySpec.CreateIndex returns an error (e.g. invalid vector dimension or unsupported index parameters in the schema), the error is wrapped with the predicate name and propagated up through addVectorEntry, aborting the bulk load for that predicate.","triggerScenarios":"Running dgraph bulk loader on a schema where a predicate has vector-type data but CreateIndex fails — typically mismatched vector dimensions vs. the schema-declared dimension, or an unsupported/invalid vector index configuration on the predicate.","commonSituations":"Schema changed after data was written (dimension mismatch); bulk loading data whose embedding size differs from the @vector(dim) in the schema; corrupted or incompatible vector index spec in the schema.","solutions":["Read the wrapped inner error and fix the underlying cause reported by CreateIndex for the named predicate.","Align vector data dimensions with the predicate's schema (e.g. float32vector @index(vector) size).","Drop and re-apply the vector index in the schema so the factory spec is regenerated, then rerun the bulk loader.","Validate the schema (dgraph schema) before bulk loading to catch dimension/spec problems early."],"exampleFix":"// before\n// schema: embedding: float32vector @index(vector) .   (data has 768-dim, schema default 4-dim mismatch)\n// after\n// schema: embedding: float32vector @index(vector(768)) .\n// then rerun: dgraph bulk -f data.rdf -s schema","handlingStrategy":"try-catch","validationCode":"// before bulk load: verify vector dims match schema\nschema, err := c.Schema(context.Background(), nil)\nif err != nil { return err }\nfor _, p := range schema.Types {\n\tif strings.Contains(p, \"float32vector\") && dataDim(p) != schemaDim(p) {\n\t\treturn fmt.Errorf(\"vector dimension mismatch on %s\", p)\n\t}\n}","typeGuard":null,"tryCatchPattern":"indexer, txn, err := vi.getOrCreateIndexer(pred)\nif err != nil {\n\tvar wrappedErr error\n\tif errors.As(err, &wrappedErr) && strings.Contains(err.Error(), \"error creating indexer\") {\n\t\tlog.Error(\"vector index creation failed\", \"pred\", pred, \"cause\", errors.Unwrap(err))\n\t\treturn fmt.Errorf(\"fix schema/data for %s: %w\", pred, errors.Unwrap(err))\n\t}\n\treturn err\n}","preventionTips":["Keep embedding dimension in sync with the schema's vector index declaration.","Validate the schema with `dgraph schema` before bulk loading.","Recreate vector indexes after schema dimension changes.","Test bulk load on a small vector dataset before full runs."],"tags":["dgraph","bulk-loader","vector-index","hnsw","schema"],"backgroundTag":"vector-index-creation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}