{"record":{"id":"30d871c1b938a40e","repo":"FlowiseAI/Flowise","slug":"error-creating-index","errorCode":null,"errorMessage":"Error creating index","messagePattern":"Error creating index","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Milvus/Milvus.ts","lineNumber":477,"sourceCode":"            })\n\n            insertDatas.push(data)\n        }\n\n        const descIndexResp = await this.client.describeIndex({\n            collection_name: this.collectionName\n        })\n\n        if (descIndexResp.status.error_code === ErrorCode.IndexNotExist) {\n            const resp = await this.client.createIndex({\n                collection_name: this.collectionName,\n                field_name: this.vectorField,\n                index_name: `myindex_${Date.now().toString()}`,\n                index_type: IndexType.AUTOINDEX,\n                metric_type: MetricType.L2\n            })\n            if (resp.error_code !== ErrorCode.SUCCESS) {\n                throw new Error(`Error creating index`)\n            }\n        }\n\n        const insertResp = await this.client.insert({\n            collection_name: this.collectionName,\n            fields_data: insertDatas\n        })\n\n        if (insertResp.status.error_code !== ErrorCode.SUCCESS) {\n            throw new Error(`Error inserting data: ${JSON.stringify(insertResp)}`)\n        }\n\n        await this.client.flushSync({ collection_names: [this.collectionName] })\n    }\n}\n\nmodule.exports = { nodeClass: Milvus_VectorStores }\n","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Milvus/Milvus.ts#L459-L495","documentation":"Thrown when the Milvus SDK's `createIndex` call returns an `error_code` other than `SUCCESS`. This branch only runs when `describeIndex` reported `IndexNotExist`, i.e. the code is attempting to lazily create an index on the vector field before insert. The index is created with `AUTOINDEX` and `MetricType.L2`.","triggerScenarios":"First insert into a collection that has no index yet, where `createIndex` fails — common causes: insufficient permissions, an unsupported `field_name`, a server that disables AUTOINDEX, or a collection still in a creating/loading state. Also fires on zilliz cloud tiers with index restrictions.","commonSituations":"New collection never indexed; permissions grant read/write but not index-admin; vector field name in the node config does not match the schema; Milvus server version does not support AUTOINDEX (older than 2.1.0).","solutions":["Check the Milvus server logs for the createIndex failure reason (the node discards it — only 'Error creating index' is surfaced).","Pre-create the index manually with `client.createIndex(...)` using an explicit index type supported by your Milvus edition (e.g. IVF_FLAT, HNSW).","Verify the user/token has index-admin privileges on the collection.","Confirm the vector field name passed to `field_name` matches the collection schema exactly.","Upgrade Milvus to a version that supports AUTOINDEX if using a managed offering that requires it."],"exampleFix":"// before — opaque failure\nif (resp.error_code !== ErrorCode.SUCCESS) {\n    throw new Error(`Error creating index`)\n}\n// after — include the server reason\nif (resp.error_code !== ErrorCode.SUCCESS) {\n    throw new Error(`Error creating index: ${JSON.stringify(resp)}`)\n}","handlingStrategy":"try-catch","validationCode":"// preflight: check supported index capability\nconst info = await this.client.getCollectionInfo({ collection_name: this.collectionName })\nif (!info) throw new Error('Collection does not exist; create it before insert')","typeGuard":"function isCreateIndexSuccess(resp: any): boolean {\n  return resp?.error_code === 0 || resp?.error_code === 'Success'\n}","tryCatchPattern":"try {\n  const resp = await this.client.createIndex({ /* ... */ })\n  if (!isCreateIndexSuccess(resp)) throw new Error(`createIndex failed: ${JSON.stringify(resp)}`)\n} catch (e) {\n  throw e instanceof Error ? e : new Error(String(e))\n}","preventionTips":["Pre-create indexes explicitly rather than relying on lazy creation.","Grant index-admin privileges to the Milvus user used by the app.","Confirm AUTOINDEX support on your Milvus edition/version.","Include the server reason in thrown errors for faster diagnosis."],"tags":["milvus","index","permissions","error-handling"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}