{"_id":"@arkie-ai/milvus-client","_rev":"1-75aaea0d640c90c5bd80d8e60f79a580","name":"@arkie-ai/milvus-client","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arkie-ai/milvus-client","version":"1.0.0","description":"node client for milvus service","main":"lib/index.js","author":{"name":"yechen","email":"yechen.li@arkie.ai"},"license":"ISC","scripts":{"build":"shx rm -rf lib && shx rm -rf lib-es && tsc --pretty -p ./tsconfig.build.json && tsc --pretty -p ./tsconfig.build.es.json","test":"node test/test.js"},"dependencies":{"@grpc/proto-loader":"^0.5.3","config":"^3.2.5","grpc":"^1.24.2"},"devDependencies":{"typescript":"^3.7.5","@types/config":"^0.0.36","shx":"^0.3.2"},"types":"lib/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/"},"_id":"@arkie-ai/milvus-client@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"arkie_ai_ops","email":"leaf.li@arkie.cn"},"dist":{"integrity":"sha512-J58oYzt7PJJWQCG+TGGsnBqqsvqrZ+Pm21+C4LFVowPD6mHlbnOxTy0ODqolAnL2u1nk6BktVXou8AkGrhOZIw==","shasum":"6f2d51e6dfda65ebc4446dce1e1e31525ead673a","tarball":"https://registry.npmjs.org/@arkie-ai/milvus-client/-/milvus-client-1.0.0.tgz","fileCount":16,"unpackedSize":49047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRP/+CRA9TVsSAnZWagAAL0UQAKJlEYyr2BHmd9Du33EO\namrjO6ABFk2jly7ZcCCCBEadnCRj+zk03PTGGIkT/csW80zfaE7UWF9AX5//\nNPQQkfx+N5ykQsiy/H6ZvBdqb02KYmLuKpfg/URUxzcYUagry+TRlRC8GrdR\nDA24+m6PRw1xQONuWbMKeE1mq4lu0YvR1Tx/Yj6HBdQEmItobtNhExW0Nhbl\nv/Zj4rwPo6QOVju5S77oNzbYUzmcIJWaSWjQTVk+U5+UKXIXsUoZ5wTH+CYN\n6tPbJ9l3ChlDonzoMn4ex4lMEhH70bSKw7PMmycDfEWeB6OKj3KcbvmGl8ud\nlpLCMH4GZe35I/frElcGTvZNJI194J/z3HA6TG8qINK9UUcY5opP5QBJ+Fwb\nrXexEf6p4UW172iWtISzJ5ZCmU4vcGMdQKPuljHpWMHx7SwI8RGLeQU5ZFIp\n6LDB7x0fdmPUwnjwpIQbCQKzuMdW/ZpNgVzZBP4p7F5xF5oOValw19YZrKAn\nCMnKsbtgAX9ukQICT49xFeakVXhLrj+L+L7NWHj8fIzEJtE1vSbBo5p16YAy\ndKlFcmejKp/BpVzhwIPJPfI4V0iuNOzhSeJ7RuJkYQYwntnnhyEDuEfTAFVB\nksIz8o6EQ+RT1Vz+nEJ1G7Yh6qwAXhyPBoNbhM1Ir4yatsmdB1NWp7onGttG\nmnz2\r\n=bcHH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEzEWG007ApN2Kkb87ITsaThi2pQ/tBOsPCXJmLEqX7ZAiBgoav9ePl29MfQYghlfo/k7/NfpG4G10wZS9NjxZU9Jg=="}]},"maintainers":[{"name":"arkie_ai_ops","email":"leaf.li@arkie.cn"},{"name":"aihornmac","email":"aihornmac@ihawn.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/milvus-client_1.0.0_1581580286299_0.013565520104869444"},"_hasShrinkwrap":false}},"time":{"created":"2020-02-13T07:51:26.099Z","1.0.0":"2020-02-13T07:51:26.397Z","modified":"2022-04-04T15:32:03.157Z"},"maintainers":[{"name":"arkie_ai_ops","email":"leaf.li@arkie.cn"},{"name":"aihornmac","email":"aihornmac@ihawn.com"}],"description":"node client for milvus service","author":{"name":"yechen","email":"yechen.li@arkie.ai"},"license":"ISC","readme":"## Milvus Node SDK\n\nThis repository is a node client for [milvus](https://github.com/milvus-io/milvus) service. It uses [gRPC](https://grpc.io/) to communicate with milvus server with [protobuf](https://developers.google.com/protocol-buffers) which is a mechanism for serializing structured data.\n\n### Getting started\n\n Assuming you are already familiar with milvus, this repository provides the some interfaces that you can use to communicate with the server of milvus.\n\n### Prerequisites\n\nBefore you start to use this package, it is recommended that you learn something about gRPC and Milvus so that you can figure out how the flow works.\n\n### Installation\n\nInstall the milvus node sdk package\n\n``` bash\nnpm install @arkie/milvus-client\n```\n\n### Interface\n\nThere are some important interfaces that you need to know.\n\n`Status`\n\nBecause it's a communication between client and server, every response comes from server will indicate that if the server is down or the operation is successful or not.\n\n``` typescript\ninterface Status {\n    error_code: string      // error code\n    reason: string          // the reason why error happens, would be empty if there are no errors\n}\n```\n\n`Error Code`\n\nThere are some error codes that indicates the error briefly. If the operation is failed, the status will carry `error_code` and `reason` to tell the user why this operation fails.\n\n``` typescript\nenum ErrorCode {\n    SUCCESS = 0;\t\t\t\t// success operation\n    UNEXPECTED_ERROR = 1;\n    CONNECT_FAILED = 2;\n    PERMISSION_DENIED = 3;\n    TABLE_NOT_EXISTS = 4;\n    ILLEGAL_ARGUMENT = 5;\n    ILLEGAL_RANGE = 6;\n    ILLEGAL_DIMENSION = 7;\n    ILLEGAL_INDEX_TYPE = 8;\n    ILLEGAL_TABLE_NAME = 9;\n    ILLEGAL_TOPK = 10;\n    ILLEGAL_ROWRECORD = 11;\n    ILLEGAL_VECTOR_ID = 12;\n    ILLEGAL_SEARCH_RESULT = 13;\n    FILE_NOT_FOUND = 14;\n    META_FAILED = 15;\n    CACHE_FAILED = 16;\n    CANNOT_CREATE_FOLDER = 17;\n    CANNOT_CREATE_FILE = 18;\n    CANNOT_DELETE_FOLDER = 19;\n    CANNOT_DELETE_FILE = 20;\n    BUILD_INDEX_ERROR = 21;\n    ILLEGAL_NLIST = 22;\n    ILLEGAL_METRIC_TYPE = 23;\n    OUT_OF_MEMORY = 24;\n}\n```\n\n### How to use\n\nNotice that every function is `async` except `clientVersion`.\n\n``` javascript\n// import the package\n// init the client with host and port\nconst Milvus = require('milvus-client')\nconst client = new Milvus.MilvusClient('localhost', 9000)\n```\n\n`clientVersion`\n\nYou can get the version of the `client` which is \"0.6.0\" for now.\n\n**Note**: it's not the package version, but the client version.\n\n``` javascript\nconst clientVersion = client.clientVersion()\n```\n\n`serverStatus`\n\nUse this function to get the status of the server to see if the server is running or not.\n\n``` javascript\n// response would be look like this\n// {\n//     status: {\n//         error_code: 'SUCCESS',\n//         reason: ''\n//     },\n//     string_reply: 'OK'\n// }\nconst serverStatus = await client.serverStatus()\n```\n\n`serverVersion`\n\nUse this function to get the version of the server.\n\n``` javascript\n// response would be look like this\n// {\n//     status: {\n//         error_code: 'SUCCESS',\n//         reason: ''\n//     },\n//     string_reply: '0.6.0'\n// }\nconst serverVersion = await client.serverVersion()\n```\n\n`serverMode`\n\nUse this function to see if the server is running with `CPU` or `GPU`.\n\n``` javascript\n// response would be look like this\n// {\n//     status: {\n//         error_code: 'SUCCESS',\n//         reason: ''\n//     },\n//     string_reply: 'CPU'\n// }\nconst serverMode = await client.serverMode()\n```\n\n`createTable`\n\nCreate a table in milvus named 'testTable' whose vector's dimension is 5 and indexFileSize is 1GB and metric_type is L2 (L2 or IP).\n\n``` javascript\n// response: Status\n// { error_code: 'SUCCESS', reason: '' }\nconst createTableResponse = await client.createTable({\n    table_name: 'testTable', // table's name\n    dimension: 5,\t         // dimension of table's vector\n    index_file_size: 1,      // must be a positive value\n    metric_type: 1, \t\t // L2 = 1, IP = 2\n})\n```\n\n`showTables`\n\nShow all tables in milvus server\n\n``` javascript\n// response\n// { status: Status, table_names: string[] }\nconst tables = await client.showTables()\n```\n\n`dropTable`\n\nDrop a table\n\n``` javascript\n// response\n// { error_code: 'SUCCESS', reason: '' }\nconst dropResponse = await client.dropTable('testTable')\n```\n\n`hasTable`\n\nCheck out if there is a table by the name of 'testTable' in the server\n\n``` javascript\n// response\n// { error_code: 'SUCCESS', reason: '' }\nconst hasTable = await client.hasTable('testTable')\n```\n\n`countTable`\n\nGet table row count\n\n``` typescript\n/**\n * @brief Get table row count\n *\n * This method is used to get table row count.\n *\n * @param table_name, target table's name.\n * @return Indicate if this operation is successful and row_count\n * \n * response example:\n * { status: Status, table_row_count: number }\n */\nconst rowCountResponse = await client.countTable('testTable')\n\n```\n\n`describeTable`\n\nDescribe information about a table\n\n``` typescript\n// response\n// {\n//   status: Status,\n//   table_name: string,\n//   dimension: number,\n//   index_file_size: number,\n//   metric_type: number\n// }\n//\n// \nconst tableInformation = await client.describeTable('testTable')\n```\n\n`createIndex`\n\nCreate index in a table\n\n**Note**: there is a default index method called 'idmap'\n\n``` javascript\n/**\n * @brief Create index method\n *\n * This method is used to create index for whole table(and its partitions).\n *\n *  @table_name: table name is going to be create index.\n *  @index_type: 0-invalid, 1-idmap, 2-ivflat, 3-ivfsq8, 4-nsgmix\n *  @nlist: index nlist\n *\n * @return Status Indicate if build index successfully.\n */\nconst createIndexResponse = await client.createIndex({\n  table_name: 'testTable',\n  index: {\n    index_type: 2,\n    nlist: 5,\n  }\n})\n```\n\n`describeIndex`\n\nDescribe the index of a table\n\n``` typescript\n// response\ninterface Index {\n  index_type: number\n  nlist: number\n}\n// { table_name: string, status: Status, index: Index, index_name: string}\nconst indexDescription = await client.describeIndex('testTable')\n```\n\n`dropIndex`\n\nDrop the index of the table except default index `idmap`\n\n``` typescript\n// response\n// { error_code: 'SUCCESS', reason: '' }\nconst dropIndexResponse = await client.dropIndex('testTable')\n```\n\n`insert`\n\nInsert some vectors into a table\n\n``` typescript\n/**\n * @brief Insert vector to table\n *\n * This method is used to insert vector array to table.\n *\n * @param table_name, target table's name.\n * @param partition_tag, target partition's tag, keep empty if no partition.\n * @param row_record_array, vector array is inserted.\n * @param row_id_array, optional\n *  specify id for each vector,\n *  if this array is empty, milvus will generate unique id for each vector,\n *  and return all ids by this parameter.\n *\n * @return Indicate if vector array are inserted successfully\n *  and if the operation is successful, then the ids of vectors will be returned too\n *\n * resposne example:\n * {\n *   status: { error_code: 'SUCCESS', reason: '' },\n *   vector_id_array: [ 123891238129, 2543534523 ] // if two vectors are inserted\n * }\n */\n\nconst insertResponse = await client.insert({\n    table_name: 'testTable',\n    partition_tag: '',\n    row_record_array: [{\n        vector_data: [1, 2, 3, 4, 5],\n    }, {\n        vector_data: [5, 4, 3, 2, 1],\n    }]\n})\n```\n\n`search`\n\nQuery similar vectors in the table 'testTable'\n\n``` typescript\n/**\n * @brief Search vector\n *\n * This method is used to query vector in table.\n *\n * @param table_name, target table's name.\n * @param partition_tag_array, target partitions, keep empty if no partition.\n * @param query_record_array, all vector are going to be queried.\n * @param query_range_array, [deprecated] time ranges, if not specified, will search in whole table\n * @param topk, how many similarity vectors will be searched.\n * @param nprobe, the number of centroids choose to search.\n *\n * @return Indicate if query is successful and vectors' id will be returned\n *\n * response example:\n * {\n *   status: { error_code: 'SUCCESS', reason: '' },\n *   ids: [ 12839129314, 2384572385 ],\n *   distances: [ 123.54, 1234.54 ],\n *   row_num: 1\n * }\n */\nconst searchResponse = await client.search({\n\ttable_name: 'testTable',\n    query_record_array: [{\n        vector_data: [1, 2, 3, 4, 5],\n    }],\n    topk: 2,\n    nprobe: 2,\n    partition_tag_array: [],\n    query_range_array: [],\n})\n\n```\n\n`deleteByDate`\n\nDelete data between two date\n\n``` typescript\n/*\n * @table_name: table's name\n * @range: date range, use 'YYYY-MM-DD' format\n *\n * @response Status\n * { error_code: 'SUCCESS', reason: '' }\n */\nconst deleteResponse = await client.deleteByDate({\n    table_name: 'testTable',\n    range: {\n        start_value: '2020-01-01',\n        end_value: '2020-02-01'\n    }\n})\n```\n\n`preloadTable`\n\nThis method is used to preload the table so that you can insert and search quickly.\n\n``` typescript\n// response\n// { error_code: 'SUCCESS', reason: '' }\nconst preloadResponse = await client.preloadTable('testTable')\n```\n\n`createPartition`\n\nCreate a partition for a table so that you can search in some partitions lately.\n\n``` typescript\n// response\n// { error_code: 'SUCCESS', reason: '' }\n// @param type PartitionParam\ninterface PartitionParam {\n    table_name: string\n    partition_name: string\n    tag: string\n}\nconst createPartitionResponse = await client.createPartition({\n    table_name: 'testTable',\n    partition_name: 'partition1',\n    tag: 'tag1',\n})\n```\n\n`showPartitions`\n\nShow all partitions in a table\n\n``` typescript\n// response\n// { status: Status, partition_array: PartitionParam[] }\nconst partitions = await client.showPartitions('testTable')\n```\n\n`dropPartition`\n\nDrop the partition that you don't want any more in a table\n\n``` typescript\n// response\n// { error_code: 'SUCCESS', reason: '' }\nconst dropPartitionResponse = await client.dropPartition({\n    table_name: 'testTable',\n    partition_name: 'partition1',\n    tag: 'tag1'\n})\n```\n\n`cmd`\n\nYou can go to milvus web site to see if there are some command that you can send to the server such as 'get_config', 'mode', 'status'...\n\n``` typescript\n// parameter is a string ---- command\n// response\n// { status: Status, stringReply: string }\nconst cmdResponse = await client.cmd('version')\n```\n\n### Version\n\nThe SDK corresponds to version 0.6.0 of the service.\n\n### Keywords\n\n`Milvus` `gRPC` `ProtoBuf` `Typescript` `Vector Search`\n\n### License\n\n","readmeFilename":"README.md"}