import { CloudClient, Schema, StringInvertedIndexConfig } from 'chromadb';
// Connect to Chroma Cloud
const client = new CloudClient({
tenant: "your-tenant",
database: "your-database",
apiKey: "your-api-key"
});
// Create a schema and disable string indexing globally
const schema = new Schema();
schema.deleteIndex(new StringInvertedIndexConfig());
// Create collection with the schema
const collection = await client.createCollection({
name: "my_collection",
schema: schema
});
// Add data - string metadata won't be indexed
await collection.add({
ids: ["id1", "id2"],
documents: ["Document 1", "Document 2"],
metadatas: [
{ category: "science", year: 2024 },
{ category: "tech", year: 2023 }
]
});
// Querying on disabled index will raise an error
try {
await collection.query({
queryTexts: ["query"],
where: { category: "science" } // Error: string index is disabled
});
} catch (e) {
console.log(`Error: ${e}`);
}