{"record":{"id":"0deb831d22006941","repo":"FlowiseAI/Flowise","slug":"error-searching-data-json-stringify-searchresp","errorCode":null,"errorMessage":"Error searching data: ${JSON.stringify(searchResp)}","messagePattern":"Error searching data: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Milvus/Milvus.ts","lineNumber":379,"sourceCode":"\n    const outputFields = vectorStore.fields.filter((field) => field !== vectorStore.vectorField)\n\n    const search_params: any = {\n        anns_field: vectorStore.vectorField,\n        topk: k.toString(),\n        metric_type: vectorStore.indexCreateParams.metric_type,\n        params: JSON.stringify(vectorStore.indexSearchParams)\n    }\n    const searchResp = await vectorStore.client.search({\n        collection_name: vectorStore.collectionName,\n        search_params,\n        output_fields: outputFields,\n        vector_type: DataType.FloatVector,\n        vectors: [query],\n        filter: filterStr\n    })\n    if (searchResp.status.error_code !== ErrorCode.SUCCESS) {\n        throw new Error(`Error searching data: ${JSON.stringify(searchResp)}`)\n    }\n    const results: [Document, number][] = []\n    searchResp.results.forEach((result) => {\n        const fields = {\n            pageContent: '',\n            metadata: {} as Record<string, any>\n        }\n        Object.keys(result).forEach((key) => {\n            if (key === vectorStore.textField) {\n                fields.pageContent = result[key]\n            } else if (vectorStore.fields.includes(key) || key === vectorStore.primaryField) {\n                if (typeof result[key] === 'string') {\n                    const { isJson, obj } = checkJsonString(result[key])\n                    fields.metadata[key] = isJson ? obj : result[key]\n                } else {\n                    fields.metadata[key] = result[key]\n                }\n            }","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Milvus/Milvus.ts#L361-L397","documentation":"Thrown by the Milvus vector store node after `client.search()` returns a response whose `status.error_code` is not `ErrorCode.SUCCESS`. The entire search response object is JSON-stringified into the message so the underlying Milvus server reason (e.g. collection not loaded, dimension mismatch, index error) is embedded in the string. It is the terminal failure of a similarity-search call, not a network error.","triggerScenarios":"Calling similarity search against a Milvus collection that is not loaded into memory, whose vector dimension does not match the query, whose index has been dropped, or whose `metric_type`/`search_params` disagree with the index. Also fires when the filter expression (`filterStr`) is malformed or references non-existent fields.","commonSituations":"Collection was created but never `loadCollectionSync`-ed (though this code calls it above, a prior failure can leave state inconsistent); query embedding model swapped to one with a different dimension; index dropped/recreated between upsert and search; wrong `topK` typed as a non-numeric string; expired Milvus credentials or zilliz cloud endpoint returning an auth error embedded in `status`.","solutions":["Inspect the JSON in the error message: read `status.reason` / `status.error_code` to get the exact Milvus failure cause.","Ensure the collection is loaded: run `client.loadCollection({ collection_name })` and wait for it before searching.","Verify the query vector dimension equals the collection schema's vector field dimension (compare `embeddings` model output length to the field definition).","Confirm `metric_type` in `search_params` matches the index's `metric_type` (L2/IP/COSINE).","Validate the filter string syntax against the currently-loaded Milvus SDK version."],"exampleFix":"// before\nif (searchResp.status.error_code !== ErrorCode.SUCCESS) {\n    throw new Error(`Error searching data: ${JSON.stringify(searchResp)}`)\n}\n// after — surface the server reason for faster diagnosis\nif (searchResp.status.error_code !== ErrorCode.SUCCESS) {\n    throw new Error(\n        `Milvus search failed (code=${searchResp.status.error_code}): ${searchResp.status.reason ?? JSON.stringify(searchResp)}`\n    )\n}","handlingStrategy":"try-catch","validationCode":"// before search: confirm collection is loaded and dims match\nconst dim = query.length\nif (!Number.isInteger(dim) || dim <= 0) {\n    throw new Error(`Invalid query vector dimension: ${dim}`)\n}\nconst loadState = await vectorStore.client.getLoadState({ collection_name: vectorStore.collectionName })\nif (loadState.state !== LoadState.Loaded) {\n    throw new Error(`Collection '${vectorStore.collectionName}' is not loaded (state=${loadState.state})`)\n}","typeGuard":"function isMilvusSuccess(resp: any): boolean {\n  return resp?.status?.error_code === 0 || resp?.status?.error_code === 'Success'\n}","tryCatchPattern":"try {\n  const searchResp = await vectorStore.client.search({ /* ... */ })\n  if (!isMilvusSuccess(searchResp)) throw new Error(`Milvus: ${searchResp.status.reason}`)\n} catch (e) {\n  // distinguish network vs server-returned error\n  throw e instanceof Error ? e : new Error(`Milvus search network error: ${String(e)}`)\n}","preventionTips":["Always load the collection and wait for LoadState.Loaded before searching.","Assert query vector dimension equals the schema's vector field dimension before each search.","Keep metric_type consistent between index creation and search_params.","Parse and surface status.reason instead of relying on the opaque JSON blob."],"tags":["milvus","vector-search","runtime","error-handling"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}