{"record":{"id":"ebaa1c0a71ae6504","repo":"chroma-core/chroma","slug":"fts-index-can-only-be-enabled-on-document-key-us","errorCode":null,"errorMessage":"FTS index can only be enabled on #document key. Use createIndex(new FtsIndexConfig(), '#document')","messagePattern":"FTS index can only be enabled on #document key\\. Use createIndex\\(new FtsIndexConfig\\(\\), '#document'\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/schema.ts","lineNumber":556,"sourceCode":"    }\n\n    // Special handling for vector index\n    if (config instanceof VectorIndexConfig) {\n      if (!keyProvided) {\n        this.setVectorIndexConfig(config);\n        return this;\n      }\n      throw new Error(\n        \"Vector index cannot be enabled on specific keys. Use createIndex(new VectorIndexConfig(...)) without specifying a key to configure the vector index globally.\",\n      );\n    }\n\n    // FTS index is only allowed on #document key\n    if (\n      config instanceof FtsIndexConfig &&\n      (!keyProvided || key !== DOCUMENT_KEY)\n    ) {\n      throw new Error(\n        \"FTS index can only be enabled on #document key. Use createIndex(new FtsIndexConfig(), '#document')\",\n      );\n    }\n\n    if (config instanceof SparseVectorIndexConfig && !keyProvided) {\n      throw new Error(\n        \"Sparse vector index must be created on a specific key. Please specify a key using: createIndex(new SparseVectorIndexConfig(...), 'your_key')\",\n      );\n    }\n\n    // TODO: Consider removing this check in the future to allow enabling all indexes for a key\n    // Disallow enabling all index types for a key (config=undefined, key=\"some_key\")\n    if (!configProvided && keyProvided && key) {\n      throw new Error(\n        `Cannot enable all index types for key '${key}'. Please specify a specific index configuration.`,\n      );\n    }\n","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/schema.ts#L538-L574","documentation":"Full-text search indexes only the document text under '#document', so FtsIndexConfig must be created with exactly that key. Calling createIndex(new FtsIndexConfig()) without a key, or with any key other than '#document', throws — the message embeds the correct invocation.","triggerScenarios":"schema.createIndex(new FtsIndexConfig()); schema.createIndex(new FtsIndexConfig(), 'body'); config catalogs that omit keys for indexes assumed to be global.","commonSituations":"Assuming the no-key 'global' pattern used for VectorIndexConfig also works for FTS; trying to rename the document field (not possible — '#document' is fixed); hand-typing the key and mistyping it.","solutions":["Use exactly: createIndex(new FtsIndexConfig(), '#document').","Import DOCUMENT_KEY from the client's schema module instead of retyping the literal string."],"exampleFix":"// before\nschema.createIndex(new FtsIndexConfig());\n\n// after\nschema.createIndex(new FtsIndexConfig(), '#document');","handlingStrategy":"validation","validationCode":"function enableFts(schema: Schema): void {\n  schema.createIndex(new FtsIndexConfig(), '#document');\n}","typeGuard":"const isDocumentFtsCall = (config: IndexConfig, key?: string | null): boolean =>\n  config instanceof FtsIndexConfig &&\n  key !== undefined && key !== null && key === '#document';","tryCatchPattern":"try {\n  schema.createIndex(config, key);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('FTS index can only be enabled on #document key')) {\n    schema.createIndex(new FtsIndexConfig(), '#document'); // retry with the exact form\n  } else {\n    throw e;\n  }\n}","preventionTips":["Use one enableFts helper so the '#document' key is typed in a single place.","Do not assume the global no-key pattern used for vector indexes applies to FTS."],"tags":["schema","index-config","full-text-search","chroma"],"backgroundTag":"invalid-index-configuration","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}