diff --git a/core/src/server/web_impl/README.md b/core/src/server/web_impl/README.md index ac447a529c839e3819aad38b71a614d20aeac381..6100894df918b9997d35316531417aa93a64c210 100644 --- a/core/src/server/web_impl/README.md +++ b/core/src/server/web_impl/README.md @@ -4,34 +4,38 @@ - [Overview](#overview) - [API Reference](#api-reference) - - [`/state`](#state) - - [`/devices`](#devices) - - [`/config/advanced` (GET)](#configadvanced-get) - - [`/config/advanced` (PUT)](#configadvanced-put) - - [`/config/advanced` (OPTIONS)](#configadvanced-options) - - [`/config/gpu_resources` (GET)](#configgpu_resources-get) - - [`/config/gpu_resources` (PUT)](#configgpu_resources-put) - - [`/config/gpu_resources` (OPTIONS)](#configgpu_resources-options) - - [`/tables` (GET)](#tables-get) - - [`/tables` (POST)](#tables-post) - - [`/tables` (OPTIONS)](#tables-options) - - [`/tables/{table_name}` (GET)](#tablestable_name-get) - - [`/tables/{table_name}` (DELETE)](#tablestable_name-delete) - - [`/tables/{table_name}` (OPTIONS)](#tablestable_name-options) - - [`/tables/{table_name}/indexes` (GET)](#tablestable_nameindexes-get) - - [`/tables/{table_name}/indexes` (POST)](#tablestable_nameindexes-post) - - [`/tables/{table_name}/indexes` (DELETE)](#tablestable_nameindexes-delete) - - [`/tables/{table_name}/indexes` (OPTIONS)](#tablestable_nameindexes-options) - - [`/tables/{table_name}/partitions` (GET)](#tablestable_namepartitions-get) - - [`/tables/{table_name}/partitions` (POST)](#tablestable_namepartitions-post) - - [`/tables/{table_name}/partitions` (OPTIONS)](#tablestable_namepartitions-options) - - [`/tables/{table_name}/partitions/{partition_tag}` (DELETE)](#tablestable_namepartitionspartition_tag-delete) - - [`/tables/{table_name}/partitions/{partition_tag}` (OPTIONS)](#tablestable_namepartitionspartition_tag-options) - - [`/tables/{table_name}/vectors` (PUT)](#tablestable_namevectors-put) - - [`/tables/{table_name}/vectors` (POST)](#tablestable_namevectors-post) - - [`/tables/{table_name}/vectors` (OPTIONS)](#tablestable_namevectors-options) - - [`/system/{msg}` (GET)](#systemmsg-get) -- [Error Codes](#error-codes) + - [`/state`](#state) + - [`/devices`](#devices) + - [`/config/advanced` (GET)](#configadvanced-get) + - [`/config/advanced` (PUT)](#configadvanced-put) + - [`/config/advanced` (OPTIONS)](#configadvanced-options) + - [`/config/gpu_resources` (GET)](#configgpu_resources-get) + - [`/config/gpu_resources` (PUT)](#configgpu_resources-put) + - [`/config/gpu_resources` (OPTIONS)](#configgpu_resources-options) + - [`/collections` (GET)](#collections-get) + - [`/collections` (POST)](#collections-post) + - [`/collections` (OPTIONS)](#collections-options) + - [`/collections/{collection_name}` (GET)](#collectionscollection_name-get) + - [`/collections/{collection_name}` (DELETE)](#collectionscollection_name-delete) + - [`/collections/{collection_name}` (OPTIONS)](#collectionscollection_name-options) + - [`/collections/{collection_name}/indexes` (GET)](#collectionscollection_nameindexes-get) + - [`/collections/{collection_name}/indexes` (POST)](#collectionscollection_nameindexes-post) + - [`/collections/{collection_name}/indexes` (DELETE)](#collectionscollection_nameindexes-delete) + - [`/collections/{collection_name}/indexes` (OPTIONS)](#collectionscollection_nameindexes-options) + - [`/collections/{collection_name}/partitions` (GET)](#collectionscollection_namepartitions-get) + - [`/collections/{collection_name}/partitions` (POST)](#collectionscollection_namepartitions-post) + - [`/collections/{collection_name}/partitions` (OPTIONS)](#collectionscollection_namepartitions-options) + - [`/collections/{collection_name}/partitions` (DELETE)](#collectionscollection_namepartitions-delete) + - [`/collections/{collection_name}/segments` (GET)](#collectionscollection_namesegments-get) + - [`/collections/{collection_name}/segments/{segment_name}/vectors` (GET)](#collectionscollection_namesegmentssegment_namevectors-get) + - [`/collections/{collection_name}/segments/{segment_name}/ids` (GET)](#collectionscollection_namesegmentssegment_nameids-get) + - [`/collections/{collection_name}/vectors` (PUT)](#collectionscollection_namevectors-put) + - [`/collections/{collection_name}/vectors` (POST)](#collectionscollection_namevectors-post) + - [`/collections/{collection_name}/vectors` (GET)](#collectionscollection_namevectorsidvector_id-get) + - [`/collections/{collection_name}/vectors` (OPTIONS)](#collectionscollection_namevectors-options) + - [`/system/{msg}` (GET)](#systemmsg-get) + - [`system/{op}` (PUT)](#systemop-put) +- [Error Codes](#error-codes) @@ -47,31 +51,31 @@ Checks whether the web server is running. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/state` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/state` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| +| Status code | Description | +| ----------- | -------------------------- | +| 200 | The request is successful. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/state" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/state" -H "accept: application/json" ``` ##### Response ```json -{"message":"Success","code":0} +{ "message": "Success", "code": 0 } ``` ### `/devices` @@ -80,33 +84,32 @@ Gets CPU/GPU information from the host. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/devices` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/devices` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | - +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/devices" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/devices" -H "accept: application/json" ``` ##### Response ```json -{"cpu":{"memory":31},"gpus":{"GPU0":{"memory":5}}} +{ "cpu": { "memory": 31 }, "gpus": { "GPU0": { "memory": 5 } } } ``` ### `/config/advanced` (GET) @@ -115,32 +118,37 @@ Gets the values of parameters in `cache_config` and `engine_config` of the Milvu #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/config/advanced` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/config/advanced` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/config/advanced" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/config/advanced" -H "accept: application/json" ``` ##### Response ```json -{"cpu_cache_capacity":4,"cache_insert_data":false,"use_blas_threshold":1100,"gpu_search_threshold":1000} +{ + "cpu_cache_capacity": 4, + "cache_insert_data": false, + "use_blas_threshold": 1100, + "gpu_search_threshold": 1000 +} ``` ### `/config/advanced` (PUT) @@ -169,33 +177,32 @@ Updates the values of parameters in `cache_config` and `engine_config` of the Mi ##### Body Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `cpu_cache_capacity` | Value of `cpu_cache_capacity` in the Milvus configuration file. The default is 4.| No | -| `cache_insert_data` | Value of `cache_insert_data` in the Milvus configuration file. The default is false. | No | -| `use_blas_threshold` | Value of `use_blas_threshold` in the Milvus configuration file. The default is 1100. | No | -| `gpu_search_threshold` | Value of `gpu_search_threshold` in the Milvus configuration file. The default is 1000. | No | +| Parameter | Description | Required? | +| ---------------------- | -------------------------------------------------------------------------------------- | --------- | +| `cpu_cache_capacity` | Value of `cpu_cache_capacity` in the Milvus configuration file. The default is 4. | No | +| `cache_insert_data` | Value of `cache_insert_data` in the Milvus configuration file. The default is false. | No | +| `use_blas_threshold` | Value of `use_blas_threshold` in the Milvus configuration file. The default is 1100. | No | +| `gpu_search_threshold` | Value of `gpu_search_threshold` in the Milvus configuration file. The default is 1000. | No | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X PUT "http://192.168.1.65:19121/config/advanced" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"cpu_cache_capacity\":4,\"cache_insert_data\":false,\"use_blas_threshold\":1100,\"gpu_search_threshold\":1000}" +$ curl -X PUT "http://127.0.0.1:19121/config/advanced" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"cpu_cache_capacity\":4,\"cache_insert_data\":false,\"use_blas_threshold\":1100,\"gpu_search_threshold\":1000}" ``` ##### Response - ```json -{"message": "OK","code": 0} +{ "message": "OK", "code": 0 } ``` ### `/config/advanced` (OPTIONS) @@ -204,20 +211,19 @@ Use this API for Cross-Origin Resource Sharing (CORS). #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/config/advanced` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | - +| Request Component | Value | +| ----------------- | ------------------ | +| Name | `/config/advanced` | +| Header | N/A | +| Body | N/A | +| Method | OPTIONS | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/config/advanced" +$ curl -X OPTIONS "http://127.0.0.1:19121/config/advanced" ``` ### `/config/gpu_resources` (GET) @@ -228,33 +234,37 @@ Gets the parameter values in `gpu_resource_config` of the Milvus configuration f #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/config/gpu_resources` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/config/gpu_resources` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/config/gpu_resources" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/config/gpu_resources" -H "accept: application/json" ``` ##### Response - ```json -{"enable":true,"cache_capacity":1,"search_resources":["GPU0"],"build_index_resources":["GPU0"]} +{ + "enable": true, + "cache_capacity": 1, + "search_resources": ["GPU0"], + "build_index_resources": ["GPU0"] +} ``` ### `/config/gpu_resources` (PUT) @@ -283,32 +293,32 @@ Updates the parameter values in `gpu_resource_config` of the Milvus configuratio ##### Body Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `enable` | Specifies whether to enable GPU resources. | Yes | -| `cache_capacity` | Size of GPU memory per card used for cache in GBs. | Yes | -| `search_resources` | GPU devices used for search computation, must be in format `gpux`. | Yes | -| `build_index_resources` | GPU devices used for index building, must be in format `gpux`. | Yes | +| Parameter | Description | Required? | +| ----------------------- | ------------------------------------------------------------------ | --------- | +| `enable` | Specifies whether to enable GPU resources. | Yes | +| `cache_capacity` | Size of GPU memory per card used for cache in GBs. | Yes | +| `search_resources` | GPU devices used for search computation, must be in format `gpux`. | Yes | +| `build_index_resources` | GPU devices used for index building, must be in format `gpux`. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X PUT "http://192.168.1.65:19121/config/gpu_resources" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"enable\":true,\"cache_capacity\":1,\"search_resources\":[\"GPU0\"],\"build_index_resources\":[\"GPU0\"]}" +$ curl -X PUT "http://127.0.0.1:19121/config/gpu_resources" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"enable\":true,\"cache_capacity\":1,\"search_resources\":[\"GPU0\"],\"build_index_resources\":[\"GPU0\"]}" ``` ##### Response ```json -{"message": "OK","code": 0} +{ "message": "OK", "code": 0 } ``` ### `/config/gpu_resources` (OPTIONS) @@ -319,67 +329,78 @@ Use this API for Cross-Origin Resource Sharing (CORS). #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/config/gpu_resources` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | +| Request Component | Value | +| ----------------- | ----------------------- | +| Name | `/config/gpu_resources` | +| Header | N/A | +| Body | N/A | +| Method | OPTIONS | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/config/gpu_resources" +$ curl -X OPTIONS "http://127.0.0.1:19121/config/gpu_resources" ``` -### `/tables` (GET) +### `/collections` (GET) -Gets all tables starting from `offset` and ends with `page_size`. +Gets all collections starting from `offset` and ends with `page_size`. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/collections` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `offset` | Row offset from which the data page starts. The default is 0. | No | -| `page_size` | Size of the data page. The default is 10. | No | - +| Parameter | Description | Required? | +| ----------- | ------------------------------------------------------------- | --------- | +| `offset` | Row offset from which the data page starts. The default is 0. | No | +| `page_size` | Size of the data page. The default is 10. | No | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/tables?offset=0&page_size=1" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/collections?offset=0&page_size=1" -H "accept: application/json" ``` ##### Response - ```json -{"tables":[{"table_name":"test_table","dimension":1,"index_file_size":10,"metric_type":"L2","count":0,"index":"FLAT","nlist":16384}],"count":58} +{ + "collections": [ + { + "collection_name": "test_collection", + "dimension": 1, + "index_file_size": 10, + "metric_type": "L2", + "count": 0, + "index": "FLAT", + "nlist": 16384 + } + ], + "count": 58 +} ``` -### `/tables` (POST) +### `/collections` (POST) -Creates a table. +Creates a collection. #### Request @@ -389,7 +410,7 @@ Creates a table. Header
accept: application/json
Body

 {
-  "table_name": string,
+  "collection_name": string,
   "dimension": integer($int64),
   "index_file_size": integer($int64),
   "metric_type": string
@@ -401,211 +422,241 @@ Creates a table.
 
 ##### Body Parameters
 
-| Parameter  | Description  |  Required? |
-|-----------------|---|------|
-| `table_name`     |   The name of the table to create, which must be unique within its database.  | Yes   |
-| `dimension`  |  The dimension of the vectors that are to be inserted into the created table. |  Yes  |
-| `index_file_size`    |  Threshold value that triggers index building for raw data files. The default is 1024.   |  No |
-| `metric_type`    |   The method vector distances are compared in Milvus. The default is L2. Currently supported metrics include `L2` (Euclidean distance), `IP` (Inner Product), `HAMMING` (Hamming distance), `JACCARD` (Jaccard distance), and `TANIMOTO` (Tanomoto distance).    |   No  |
+| Parameter         | Description                                                                                                                                                                                                                                                 | Required? |
+| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
+| `collection_name` | The name of the collection to create, which must be unique within its database.                                                                                                                                                                             | Yes       |
+| `dimension`       | The dimension of the vectors that are to be inserted into the created collection.                                                                                                                                                                           | Yes       |
+| `index_file_size` | Threshold value that triggers index building for raw data files. The default is 1024.                                                                                                                                                                       | No        |
+| `metric_type`     | The method vector distances are compared in Milvus. The default is L2. Currently supported metrics include `L2` (Euclidean distance), `IP` (Inner Product), `HAMMING` (Hamming distance), `JACCARD` (Jaccard distance), and `TANIMOTO` (Tanomoto distance). | No        |
 
 #### Response
 
-| Status code    | Description |
-|-----------------|---|
-| 201     | Created |
-| 400     | The request is incorrect. Refer to the error message for details. |
+| Status code | Description                                                       |
+| ----------- | ----------------------------------------------------------------- |
+| 201         | Created                                                           |
+| 400         | The request is incorrect. Refer to the error message for details. |
 
 #### Example
 
 ##### Request
 
 ```shell
-$ curl -X POST "http://192.168.1.65:19121/tables" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"table_name\":\"test_table\",\"dimension\":1,\"index_file_size\":10,\"metric_type\":\"L2\"}"
+$ curl -X POST "http://127.0.0.1:19121/collections" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"collection_name\":\"test_collection\",\"dimension\":1,\"index_file_size\":10,\"metric_type\":\"L2\"}"
 ```
 
 ##### Response
 
-
 ```json
-{"message":"OK","code":0}
+{ "message": "OK", "code": 0 }
 ```
 
-### `/tables` (OPTIONS)
+### `/collections` (OPTIONS)
 
 Use this API for Cross-Origin Resource Sharing (CORS).
 
 #### Request
 
-| Request Component     | Value  |
-|-----------------|---|
-| Name     | `/tables`  |
-| Header  | N/A  |
-| Body    |   N/A |
-| Method    |   OPTIONS |
-
+| Request Component | Value          |
+| ----------------- | -------------- |
+| Name              | `/collections` |
+| Header            | N/A            |
+| Body              | N/A            |
+| Method            | OPTIONS        |
 
 #### Example
 
 ##### Request
 
 ```shell
-$ curl -X OPTIONS "http://192.168.1.65:19121/tables"
+$ curl -X OPTIONS "http://127.0.0.1:19121/collections"
 ```
 
-### `/tables/{table_name}` (GET)
+### `/collections/{collection_name}` (GET)
 
-Gets all information about a table by name.
+Gets all information about a collection by name.
 
 #### Request
 
-| Request Component     | Value  |
-|-----------------|---|
-| Name     | `/tables/{table_name}`  |
-| Header  | `accept: application/json`  |
-| Body    |   N/A |
-| Method    |   GET |
-
+| Request Component | Value                            |
+| ----------------- | -------------------------------- |
+| Name              | `/collections/{collection_name}` |
+| Header            | `accept: application/json`       |
+| Body              | N/A                              |
+| Method            | GET                              |
 
 ##### Query Parameters
 
-| Parameter  | Description  |  Required? |
-|-----------------|---|------|
-| `table_name`     | Name of the table.   | Yes   |
-
+| Parameter         | Description                                                                                                                                                                                                                                                                                                               | Required? |
+| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
+| `collection_name` | Name of the collection.                                                                                                                                                                                                                                                                                                   | Yes       |
+| `info`            | Type of information to acquire. `info` must either be empty or `stat`. When `info` is empty, Milvus returns collection name, dimension, index file size, metric type, offset, index type, and nlist of the collection. When `info` is `stat`, Milvus returns the collection offset, partition status, and segment status. | No        |
 
 #### Response
 
-| Status code    | Description |
-|-----------------|---|
-| 200     | The request is successful.|
-| 400     | The request is incorrect. Refer to the error message for details. |
-| 404     | The required resource does not exist. |
+| Status code | Description                                                       |
+| ----------- | ----------------------------------------------------------------- |
+| 200         | The request is successful.                                        |
+| 400         | The request is incorrect. Refer to the error message for details. |
+| 404         | The required resource does not exist.                             |
 
 #### Example
 
 ##### Request
 
 ```shell
-$ curl -X GET "http://192.168.1.65:19121/tables/test_table" -H "accept: application/json"
+$ curl -X GET "http://127.0.0.1:19121/collections/test_collection" -H "accept: application/json"
 ```
 
 ##### Response
 
 ```json
-{"table_name":"test_table","dimension":1,"index_file_size":10,"metric_type":"L2","count":0,"index":"FLAT","nlist":16384}
+{
+  "collection_name": "test_collection",
+  "dimension": 1,
+  "index_file_size": 10,
+  "metric_type": "L2",
+  "count": 0,
+  "index": "FLAT",
+  "index_params": {}
+}
+```
+
+##### Request
+
+```shell
+$ curl -X GET "http://127.0.0.1:19121/collections/test_collection?info=stat" -H "accept: application/json"
+```
+
+##### Response
+
+```json
+{
+  "count": 150000,
+  "partitions_stat": [
+    {
+      "count": 1000,
+      "partition_tag": "_default",
+      "segments_stat": [
+        {
+          "count": 1000,
+          "index": "IVFFLAT",
+          "segment_name": "1583727170217439000",
+          "size": 5284922
+        }
+      ]
+    }
+  ]
+}
 ```
 
-### `/tables/{table_name}` (DELETE)
+### `/collections/{collection_name}` (DELETE)
 
-Drops a table by name.
+Drops a collection by name.
 
 #### Request
 
-| Request Component     | Value  |
-|-----------------|-----|
-| Name     | `/tables/{table_name}`  |
-| Header  | `accept: application/json`  |
-| Body    |   N/A |
-| Method    |   DELETE |
+| Request Component | Value                            |
+| ----------------- | -------------------------------- |
+| Name              | `/collections/{collection_name}` |
+| Header            | `accept: application/json`       |
+| Body              | N/A                              |
+| Method            | DELETE                           |
 
 ##### Query Parameters
 
-| Parameter  | Description  |  Required? |
-|-----------------|---|------|
-| `table_name`     | Name of the table.   | Yes   |
+| Parameter         | Description             | Required? |
+| ----------------- | ----------------------- | --------- |
+| `collection_name` | Name of the collection. | Yes       |
 
 #### Response
 
-| Status code    | Description |
-|-----------------|---|
-| 204     | Deleted|
-| 400     | The request is incorrect. Refer to the error message for details. |
-| 404     | The required resource does not exist. |
+| Status code | Description                                                       |
+| ----------- | ----------------------------------------------------------------- |
+| 204         | Deleted                                                           |
+| 400         | The request is incorrect. Refer to the error message for details. |
+| 404         | The required resource does not exist.                             |
 
 #### Example
 
 ##### Request
 
-
 ```shell
-$ curl -X DELETE "http://192.168.1.65:19121/tables/test_table" -H "accept: application/json"
+$ curl -X DELETE "http://127.0.0.1:19121/collections/test_collection" -H "accept: application/json"
 ```
 
 If the deletion is successful, no message will be returned.
 
-### `/tables/{table_name}` (OPTIONS)
+### `/collections/{collection_name}` (OPTIONS)
 
 Use this API for Cross-Origin Resource Sharing (CORS).
 
 #### Request
 
-| Request Component     | Value  |
-|-----------------|-----|
-| Name     | `/tables/{table_name}`  |
-| Header  | N/A  |
-| Body    |   N/A |
-| Method    |   OPTIONS |
+| Request Component | Value                            |
+| ----------------- | -------------------------------- |
+| Name              | `/collections/{collection_name}` |
+| Header            | N/A                              |
+| Body              | N/A                              |
+| Method            | OPTIONS                          |
 
 #### Query Parameters
 
-| Parameter  | Description  |  Required? |
-|-----------------|---|------|
-| `table_name`     | Name of the table.   | Yes   |
-
+| Parameter         | Description             | Required? |
+| ----------------- | ----------------------- | --------- |
+| `collection_name` | Name of the collection. | Yes       |
 
 #### Example
 
 ##### Request
 
 ```shell
-$ curl -X OPTIONS "http://192.168.1.65:19121/tables/test_table"
+$ curl -X OPTIONS "http://127.0.0.1:19121/collections/test_collection"
 ```
 
-### `/tables/{table_name}/indexes` (GET)
+### `/collections/{collection_name}/indexes` (GET)
 
-Gets the index type and nlist of a table.
+Gets the index type and nlist of a collection.
 
 #### Request
 
-| Request Component     | Value  |
-|-----------------|-----|
-| Name     | `/tables/{table_name}/indexes`  |
-| Header  | `accept: application/json`  |
-| Body    |   N/A |
-| Method    |   GET |
+| Request Component | Value                                    |
+| ----------------- | ---------------------------------------- |
+| Name              | `/collections/{collection_name}/indexes` |
+| Header            | `accept: application/json`               |
+| Body              | N/A                                      |
+| Method            | GET                                      |
 
 ##### Query Parameters
 
-| Parameter  | Description  |  Required? |
-|-----------------|---|------|
-| `table_name`     | Name of the table.   | Yes   |
+| Parameter         | Description             | Required? |
+| ----------------- | ----------------------- | --------- |
+| `collection_name` | Name of the collection. | Yes       |
 
 #### Response
 
-| Status code    | Description |
-|-----------------|---|
-| 200     | The request is successful.|
-| 400     | The request is incorrect. Refer to the error message for details. |
-| 404     | The required resource does not exist. |
+| Status code | Description                                                       |
+| ----------- | ----------------------------------------------------------------- |
+| 200         | The request is successful.                                        |
+| 400         | The request is incorrect. Refer to the error message for details. |
+| 404         | The required resource does not exist.                             |
 
 #### Example
 
 ##### Request
 
 ```shell
-$ curl -X GET "http://192.168.1.65:19121/tables/test_table/indexes" -H "accept: application/json"
+$ curl -X GET "http://127.0.0.1:19121/collections/test_collection/indexes" -H "accept: application/json"
 ```
 
 ##### Response
 
-
 ```json
-{"index_type":"FLAT","nlist":16384}
+{ "index_type": "FLAT", "params": { "nlist": 4096 } }
 ```
 
-### `/tables/{table_name}/indexes` (POST)
+### `/collections/{collection_name}/indexes` (POST)
 
-Updates the index type and nlist of a table.
+Updates the index type and nlist of a collection.
 
 #### Request
 
@@ -616,7 +667,9 @@ Updates the index type and nlist of a table.
 Body

 {
   "index_type": string,
-  "nlist": integer($int64)
+  "params": {
+      ......
+  }
 }
 
MethodPOST @@ -625,288 +678,419 @@ Updates the index type and nlist of a table. ##### Body Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `index_type` | The type of indexing method to query the table. Please refer to [Index Types](https://www.milvus.io/docs/reference/index.md) for detailed introduction of supported indexes. The default is "FLAT". | No | -| `nlist` | Number of vector buckets in a file. The default is 16384. | No | +| Parameter | Description | Required? | +| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| `index_type` | The type of indexing method to query the collection. Please refer to [Index Types](https://www.milvus.io/docs/reference/index.md) for detailed introduction of supported indexes. The default is "FLAT". | No | +| `params` | The extra params of indexing method to query the collection. Please refer to - [Index params](#index_param) for detailed introduction of supported indexes. | No | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 201 | Created | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | - -#### Response - -| Status code | Description | -|-----------------|---| -| 201 | Created | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 201 | Created | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X POST "http://192.168.1.65:19121/tables/test_table/indexes" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"index_type\":\"FLAT\",\"nlist\":16384}" +$ curl -X POST "http://127.0.0.1:19121/collections/test_collection/indexes" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"index_type\":\"IVFFLAT\",\"params\": {\"nlist\":4096}}" ``` ##### Response ```json -{"message":"OK","code":0} +{ "message": "OK", "code": 0 } ``` -### `/tables/{table_name}/indexes` (DELETE) +### `/collections/{collection_name}/indexes` (DELETE) -Drops an index for a table. +Drops an index for a collection. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables/{table_name}/indexes` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | DELETE | +| Request Component | Value | +| ----------------- | ---------------------------------------- | +| Name | `/collections/{collection_name}/indexes` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | DELETE | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 204 | Deleted | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | Resource not available | - +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 204 | Deleted | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | Resource not available | #### Example ##### Request ```shell -$ curl -X DELETE "http://192.168.1.65:19121/tables/test_table/indexes" -H "accept: application/json" +$ curl -X DELETE "http://127.0.0.1:19121/collections/test_collection/indexes" -H "accept: application/json" ``` If the deletion is successful, no message will be returned. - -### `/tables/{table_name}/indexes` (OPTIONS) +### `/collections/{collection_name}/indexes` (OPTIONS) Use this API for Cross-Origin Resource Sharing (CORS). #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables/{table_name}/indexes` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | +| Request Component | Value | +| ----------------- | ---------------------------------------- | +| Name | `/collections/{collection_name}/indexes` | +| Header | N/A | +| Body | N/A | +| Method | OPTIONS | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/tables/test_table/indexes" +$ curl -X OPTIONS "http://127.0.0.1:19121/collections/test_collection/indexes" ``` -### `/tables/{table_name}/partitions` (GET) +### `/collections/{collection_name}/partitions` (GET) -Gets all partitions in a table starting from `offset` and ends with `page_size`. +Gets all partitions in a collection starting from `offset` and ends with `page_size`. #### Request -| Request Component | Value | -|-----------------|-----------| -| Name | `/tables/{table_name}/partitions` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | ------------------------------------------- | +| Name | `/collections/{collection_name}/partitions` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | -| `offset` | Row offset from which the data page starts. The default is 0. | No | -| `page_size` | Size of the data page. The default is 10. | No | +| Parameter | Description | Required? | +| ----------------- | ------------------------------------------------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | +| `offset` | Row offset from which the data page starts. The default is 0. | No | +| `page_size` | Size of the data page. The default is 10. | No | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/tables/test_table/partitions?offset=0&page_size=3" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/collections/test_collection/partitions?offset=0&page_size=3" -H "accept: application/json" ``` ##### Response ```json -{"partitions":[{"partition_name":"partition_1","partition_tag":"test_tag"},{"partition_name":"partition_2","partition_tag":"test_2"},{"partition_name":"partition_3","partition_tag":"test_3"}]} +{ + "partitions": [ + { "partition_tag": "_default" }, + { "partition_tag": "test_tag" }, + { "partition_tag": "test_2" } + ], + "count": 10 +} ``` -### `/tables/{table_name}/partitions` (POST) +### `/collections/{collection_name}/partitions` (POST) -Creates a partition in a table. +Creates a partition in a collection. #### Request -| Request Component | Value | -|-----------------|-----------| -| Name | `/tables/{table_name}/partitions` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | POST | +| Request Component | Value | +| ----------------- | ------------------------------------------- | +| Name | `/collections/{collection_name}/partitions` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | POST | #### Response -| Status code | Description | -|-----------------|---| -| 201 | Created | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 201 | Created | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X POST "http://192.168.1.65:19121/tables/test_table/partitions" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"partition_name\": \"partition_1\",\"partition_tag\": \"test\"}" +$ curl -X POST "http://127.0.0.1:19121/collections/test_collection/partitions" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"partition_tag\": \"test\"}" ``` ##### Response ```json -{"message":"OK","code":0} +{ "message": "OK", "code": 0 } ``` -### `/tables/{table_name}/partitions` (OPTIONS) +### `/collections/{collection_name}/partitions` (OPTIONS) Use this API for Cross-Origin Resource Sharing (CORS). #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables/{table_name}/partitions` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | +| Request Component | Value | +| ----------------- | ------------------------------------------- | +| Name | `/collections/{collection_name}/partitions` | +| Header | N/A | +| Body | N/A | +| Method | OPTIONS | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | - +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/tables/test_table/partitions" +$ curl -X OPTIONS "http://127.0.0.1:19121/collections/test_collection/partitions" ``` -### `/tables/{table_name}/partitions/{partition_tag}` (DELETE) +### `/collections/{collection_name}/partitions` (DELETE) Deletes a partition by tag. #### Request -| Request Component | Value | -|-----------------|-----------| -| Name | `/tables/{table_name}/partitions/{partition_tag}` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | DELETE | + + + + + + + +
Request ComponentValue
Name
/collections/{collection_name}/partitions
Header
accept: application/json
Body

+{
+  "partition_tag": string
+}
+
MethodPOST
##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table that contains the partition. | Yes | -| `partition_tag` | Tag of the partition to delete. | yes | +| Parameter | Description | Required? | +| ----------------- | --------------------------------------------------- | --------- | +| `collection_name` | Name of the collection that contains the partition. | Yes | +| `partition_tag` | Tag of the partition to delete. | yes | #### Response -| Status code | Description | -|-----------------|---| -| 204 | Deleted | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The requested resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 204 | Deleted | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The requested resource does not exist. | #### Example ##### Request ```shell -$ curl -X DELETE "http://192.168.1.65:19121/tables/test_table/partitions/tags_01" -H "accept: application/json" +$ curl -X DELETE "http://127.0.0.1:19121/collections/test_collection/partitions -H "accept: application/json" -d "{\"partition_tag\": \"tags_01\"}" ``` The deletion is successful if no information is returned. -### `/tables/{table_name}/partitions/{partition_tag}` (OPTIONS) +### `/collections/{collection_name}/segments` (GET) -Use this API for Cross-Origin Resource Sharing (CORS). +Gets all segments in a collection starting from `offset` and ends with `page_size`. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables/{table_name}/partitions/{partition_tag}` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | +| Request Component | Value | +| ----------------- | ----------------------------------------- | +| Name | `/collections/{collection_name}/segments` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | -| `partition_tag` | Tag of the partition | yes | +| Parameter | Description | Required? | +| ----------------- | ------------------------------------------------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | +| `offset` | Row offset from which the data page starts. The default is 0. | No | +| `page_size` | Size of the data page. The default is 10. | No | + +#### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/tables/test_table/partitions/tag" +$ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments?offset=0&page_size=1" -H "accept: application/json" +``` + +##### Response + +```json +{ + "code": 0, + "message": "OK", + "count": 2, + "segments": [ + { + "count": 10000, + "index": "IVFFLAT", + "partition_tag": "_default", + "segment_name": "1583727470444700000", + "size": 5284922 + } + ] +} ``` -### `/tables/{table_name}/vectors` (PUT) +### `/collections/{collection_name}/segments/{segment_name}/vectors` (GET) -Searches vectors in a table. +Gets all vectors of segment in a collection starting from `offset` and ends with `page_size`. + +#### Request + +| Request Component | Value | +| ----------------- | ----------------------------------------- | +| Name | `/collections/{collection_name}/segments` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | + +##### Query Parameters + +| Parameter | Description | Required? | +| ----------------- | ------------------------------------------------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | +| `segment_name` | Name of the segment. | Yes | +| `offset` | Row offset from which the data page starts. The default is 0. | No | +| `page_size` | Size of the data page. The default is 10. | No | + +#### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | + +#### Example + +##### Request + +```shell +$ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/1583727470444700000/vectors?offset=0&page_size=1" -H "accept: application/json" +``` + +##### Response + +```json +{ + "code": 0, + "message": "OK", + "count": 2, + "vectors": [ + { + "vector": [0.1], + "id": "1583727470435045000" + } + ] +} +``` + +### `/collections/{collection_name}/segments/{segment_name}/ids` (GET) + +Gets all vector ids of segment in a collection starting from `offset` and ends with `page_size`. + +#### Request + +| Request Component | Value | +| ----------------- | ----------------------------------------- | +| Name | `/collections/{collection_name}/segments` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | + +##### Query Parameters + +| Parameter | Description | Required? | +| ----------------- | ------------------------------------------------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | +| `segment_name` | Name of the segment. | Yes | +| `offset` | Row offset from which the data page starts. The default is 0. | No | +| `page_size` | Size of the data page. The default is 10. | No | + +#### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | + +#### Example + +##### Request + +```shell +$ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/1583727470444700000/ids?offset=0&page_size=1" -H "accept: application/json" +``` + +##### Response + +```json +{ + "ids": ["1583727470435045000"], + "count": 10000 +} +``` + +### `/collections/{collection_name}/vectors` (PUT) + +1. Searches vectors in a collection. #### Request @@ -916,12 +1100,15 @@ Searches vectors in a table. Header
accept: application/json
Body

 {
-  "topk": integer($int64),
-  "nprobe": integer($int64),
-  "tags": [string],
-  "file_ids": [string],
-  "records": [[number($float)]],
-  "records_bin": [[number($uint64)]]
+  "search": {
+      "topk": integer($int64),
+      "partition_tags": [string],
+      "file_ids": [string],
+      "vectors": [[number($float/$uint8)]]
+      "params": {
+          "nprobe": 16
+      }
+  }
 }
 
MethodPUT @@ -929,49 +1116,107 @@ Searches vectors in a table. ##### Body Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `topk` | The top k most similar results of each query vector. | Yes | -| `nprobe` | Number of queried vector buckets. | Yes | -| `tags` | Tags of partitions that you need to search. You do not have to specify this value if the table is not partitioned or you wish to search the whole table. | No | -| `file_ids` | IDs of the vector files. You do not have to specify this value if you do not use Milvus in distributed scenarios. Also, if you assign a value to `file_ids`, the value of `tags` is ignored. | No | -| `records` | Numeric vectors to insert to the table. | Yes | -| `records_bin` | Binary vectors to insert to the table. | Yes | +| Parameter | Description | Required? | +| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| `topk` | The top k most similar results of each query vector. | Yes | +| `tags` | Tags of partitions that you need to search. You do not have to specify this value if the collection is not partitioned or you wish to search the whole collection. | No | +| `file_ids` | IDs of the vector files. You do not have to specify this value if you do not use Milvus in distributed scenarios. Also, if you assign a value to `file_ids`, the value of `tags` is ignored. | No | +| `vectors` | Vectors to query. | Yes | +| `params` | Extra params for search. Please refer to [Search param](#index_param) to get more detail information. | Yes | + +> Note: Type of items of vectors depends on the metric used by the collection. If the collection uses `L2` or `IP`, you must use `float`. If the collection uses `HAMMING`, `JACCARD`, or `TANIMOTO`, you must use `uint8`. -> Note: Select `records` or `records_bin` depending on the metric used by the table. If the table uses `L2` or `IP`, you must use `records`. If the table uses `HAMMING`, `JACCARD`, or `TANIMOTO`, you must use `records_bin`. +##### Query Parameters + +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | + +#### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | + +#### Example + +##### Request + +```shell +$ curl -X PUT "http://127.0.0.1:19121/collections/test_collection/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"topk\":2,\"vectors\":[[0.1]], \"params\":{\"nprobe\":16}}" +``` +##### Response + +```json +{ + "num": 1, + "results": [ + [ + { "id": "1578989029645098000", "distance": "0.000000" }, + { "id": "1578989029645098001", "distance": "0.010000" } + ] + ] +} +``` + +2. Delete vectors + +#### Request + + + + + + + +
Request ComponentValue
Name
/tables/{table_name}/vectors
Header
accept: application/json
Body

+{
+  "delete": {
+     "ids": [$string]
+  }
+}
+
MethodPUT
+ +##### Body Parameters + +| Parameter | Description | Required? | +| --------- | --------------- | --------- | +| ids | IDs of vectors. | Yes | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X PUT "http://192.168.1.65:19121/tables/test_table/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"topk\":2,\"nprobe\":16,\"records\":[[0.1]]}" +$ curl -X PUT "http://127.0.0.1:19121/collections/test_collection/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{"delete": {"ids": ["1578989029645098000"]}}" ``` ##### Response ```json -{"num":1,"results":[[{"id":"1578989029645098000","distance":"0.000000"},{"id":"1578989029645098001","distance":"0.010000"}]]} +{ "code": 0, "message": "success" } ``` -### `/tables/{table_name}/vectors` (POST) +### `/collections/{collection_name}/vectors` (POST) -Inserts vectors to a table. +Inserts vectors to a collection. > Note: It is recommended that you do not insert more than 1 million vectors per request. @@ -983,9 +1228,8 @@ Inserts vectors to a table. Header
accept: application/json
Body

 {
-  "tag": string,
-  "records": [[number($float)]],
-  “records_bin”:[[number($uint64)]]
+  "partition_tag": string,
+  "vectors": [[number($float/$uint8)]],
   "ids": [integer($int64)]
 }
 
@@ -994,62 +1238,117 @@ Inserts vectors to a table. ##### Body Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `tag` | Tag of the partition to insert vectors to. | No | -| `records` | Numeric vectors to insert to the table. | Yes | -| `records_bin` | Binary vectors to insert to the table. | Yes | -| `ids` | IDs of the vectors to insert to the table. If you assign IDs to the vectors, you must provide IDs for all vectors in the table. If you do not specify this parameter, Milvus automatically assigns IDs to the vectors. | No | +| Parameter | Description | Required? | +| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| `partition_tag` | Tag of the partition to insert vectors to. | No | +| `vectors` | Vectors to insert to the collection. | Yes | +| `ids` | IDs of the vectors to insert to the collection. If you assign IDs to the vectors, you must provide IDs for all vectors in the collection. If you do not specify this parameter, Milvus automatically assigns IDs to the vectors. | No | -> Note: Select `records` or `records_bin` depending on the metric used by the table. If the table uses `L2` or `IP`, you must use `records`. If the table uses `HAMMING`, `JACCARD`, or `TANIMOTO`, you must use `records_bin`. +> Note: Type of items of `vectors` depends on the metric used by the collection. If the collection uses `L2` or `IP`, you must use `float`. If the collection uses `HAMMING`, `JACCARD`, or `TANIMOTO`, you must use `uint8`. ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `table_name` | Name of the table. | Yes | +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | + +#### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 201 | Created | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | + +#### Example + +##### Request + +```shell +$ curl -X POST "http://127.0.0.1:19121/collections/test_collection/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"vectors\":[[0.1],[0.2],[0.3],[0.4]]}" +``` + +##### Response + +```json +{ + "ids": [ + "1578989029645098000", + "1578989029645098001", + "1578989029645098002", + "1578989029645098003" + ] +} +``` + +### `/collections/{collection_name}/vectors?id={vector_id}` (GET) + +Obtain a vector to by ID. + +#### Request + +| Request Component | Value | +| ----------------- | ---------------------------------------- | +| Name | `/collections/{collection_name}/vectors` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | + +#### Query Parameters + +| Parameter | Description | Required? | +| ----------------- | ----------------------- | --------- | +| `collection_name` | Name of the collection. | Yes | +| `vector_id` | Vector id. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 201 | Created | -| 400 | The request is incorrect. Refer to the error message for details. | -| 404 | The required resource does not exist. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 201 | Created | +| 400 | The request is incorrect. Refer to the error message for details. | +| 404 | The required resource does not exist. | #### Example ##### Request ```shell -$ curl -X POST "http://192.168.1.65:19121/tables/test_table/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"records\":[[0.1],[0.2],[0.3],[0.4]]}" +$ curl -X POST "http://127.0.0.1:19121/collections/test_collection/vectors?id=1578989029645098000" -H "accept: application/json" -H "Content-Type: application/json" ``` ##### Response ```json -{"ids":["1578989029645098000","1578989029645098001","1578989029645098002","1578989029645098003"]} +{ + "vectors": [ + { + "id": "1578989029645098000", + "vector": [0.1] + } + ] +} ``` -### `/tables/{table_name}/vectors` (OPTIONS) +### `/collections/{collection_name}/vectors` (OPTIONS) Use this API for Cross-Origin Resource Sharing (CORS). #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/tables/{table_name}/vectors` | -| Header | N/A | -| Body | N/A | -| Method | OPTIONS | +| Request Component | Value | +| ----------------- | ---------------------------------------- | +| Name | `/collections/{collection_name}/vectors` | +| Header | N/A | +| Body | N/A | +| Method | OPTIONS | #### Example ##### Request ```shell -$ curl -X OPTIONS "http://192.168.1.65:19121/tables/test_table/vectors" +$ curl -X OPTIONS "http://127.0.0.1:19121/collections/test_collection/vectors" ``` ### `/system/{msg}` (GET) @@ -1058,72 +1357,229 @@ Gets information about the Milvus server. #### Request -| Request Component | Value | -|-----------------|---| -| Name | `/system/{msg}` | -| Header | `accept: application/json` | -| Body | N/A | -| Method | GET | +| Request Component | Value | +| ----------------- | -------------------------- | +| Name | `/system/{msg}` | +| Header | `accept: application/json` | +| Body | N/A | +| Method | GET | ##### Query Parameters -| Parameter | Description | Required? | -|-----------------|---|------| -| `msg` | Type of the message to return. You can use `status` or `version`. | Yes | +| Parameter | Description | Required? | +| --------- | ----------------------------------------------------------------- | --------- | +| `msg` | Type of the message to return. You can use `status` or `version`. | Yes | #### Response -| Status code | Description | -|-----------------|---| -| 200 | The request is successful.| -| 400 | The request is incorrect. Refer to the error message for details. | +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | #### Example ##### Request ```shell -$ curl -X GET "http://192.168.1.65:19121/system/version" -H "accept: application/json" +$ curl -X GET "http://127.0.0.1:19121/system/version" -H "accept: application/json" +``` + +##### Response + +```json +{ "reply": "0.7.0" } +``` + +### `system/{op}` (PUT) + +#### Flush a collection + +##### Request + + + + + + + +
Request ComponentValue
Name
/system/task
Header
accept: application/json
Body

+{
+  "flush": {
+     "collection_names": [$string]
+  }
+}
+
MethodPUT
+ +##### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | + +##### Example + +###### Request + +```shell +$ curl -X PUT "http://127.0.0.1:19121/system/task" -H "accept: application/json" -d "{\"flush\": {\"collection_names\": [\"test_collection\"]}}" +``` + +###### Response + +```json +{ "code": 0, "message": "success" } +``` + +#### Compact segments in a collection + +##### Request + + + + + + + +
Request ComponentValue
Name
/system/task
Header
accept: application/json
Body

+{
+  "compact": {
+     "collection_name": $string
+  }
+}
+
MethodPUT
+ +##### Response + +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | + +##### Example + +###### Request + +```shell +$ curl -X PUT "http://127.0.0.1:19121/system/task" -H "accept: application/json" -d "{\"compact\": {\"collection_name\": \"test_collection\"}}" +``` + +###### Response + +```json +{ "code": 0, "message": "success" } ``` +#### Load a collection to memory + +##### Request + + + + + + + +
Request ComponentValue
Name
/system/task
Header
accept: application/json
Body

+{
+  "load": {
+     "collection_name": $string
+  }
+}
+
MethodPUT
+ ##### Response +| Status code | Description | +| ----------- | ----------------------------------------------------------------- | +| 200 | The request is successful. | +| 400 | The request is incorrect. Refer to the error message for details. | + +##### Example + +###### Request + +```shell +$ curl -X PUT "http://127.0.0.1:19121/system/task" -H "accept: application/json" -d "{\"load\": {\"collection_name\": \"test_collection\"}}" +``` + +###### Response + ```json -{"reply":"0.6.0"} +{ "code": 0, "message": "success" } ``` +## Index parameters + +For each index type, the RESTful API has specific index parameters and search parameters. + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index typeCreate index paramSearch param
IVFFLAT
{"nlist": $int}
{"nprobe": $int}
IVFPQ
{"m": $int, "nlist": $int}
{"nprobe": $int}
IVFSQ8
{"nlist": $int}
{"nprobe": $int}
IVFSQ8H
{"nlist": $int}
{"nprobe": $int}
HNSW
{"M": $int, "efConstruction": $int}
{"ef": $int}
+ +For detailed information about the parameters above, refer to [Index Types](https://milvus.io/docs/v0.7.0/reference/index.md) + ## Error Codes The RESTful API returns error messages as JSON text. Each type of error message has a specific error code. -| Type | Code | -|----------|------| -SUCCESS | 0 | -UNEXPECTED_ERROR | 1 | -CONNECT_FAILED | 2 | -PERMISSION_DENIED | 3 | -TABLE_NOT_EXISTS | 4 | -ILLEGAL_ARGUMENT | 5 | -ILLEGAL_RANGE | 6 | -ILLEGAL_DIMENSION | 7 | -ILLEGAL_INDEX_TYPE | 8 | -ILLEGAL_TABLE_NAME | 9 | -ILLEGAL_TOPK | 10 | -ILLEGAL_ROWRECORD | 11 | -ILLEGAL_VECTOR_ID | 12 | -ILLEGAL_SEARCH_RESULT | 13 | -FILE_NOT_FOUND | 14 | -META_FAILED | 15 | -CACHE_FAILED | 16 | -CANNOT_CREATE_FOLDER | 17 | -CANNOT_CREATE_FILE | 18 | -CANNOT_DELETE_FOLDER | 19 | -CANNOT_DELETE_FILE | 20 | -BUILD_INDEX_ERROR | 21 | -ILLEGAL_NLIST | 22 | -ILLEGAL_METRIC_TYPE | 23 | -OUT_OF_MEMORY | 24 | -PATH_PARAM_LOSS | 31 | -QUERY_PARAM_LOSS | 32 | -BODY_FIELD_LOSS | 33 | -ILLEGAL_QUERY_PARAM | 36 | +| Type | Code | +| --------------------- | ---- | +| SUCCESS | 0 | +| UNEXPECTED_ERROR | 1 | +| CONNECT_FAILED | 2 | +| PERMISSION_DENIED | 3 | +| TABLE_NOT_EXISTS | 4 | +| ILLEGAL_ARGUMENT | 5 | +| ILLEGAL_RANGE | 6 | +| ILLEGAL_DIMENSION | 7 | +| ILLEGAL_INDEX_TYPE | 8 | +| ILLEGAL_TABLE_NAME | 9 | +| ILLEGAL_TOPK | 10 | +| ILLEGAL_ROWRECORD | 11 | +| ILLEGAL_VECTOR_ID | 12 | +| ILLEGAL_SEARCH_RESULT | 13 | +| FILE_NOT_FOUND | 14 | +| META_FAILED | 15 | +| CACHE_FAILED | 16 | +| CANNOT_CREATE_FOLDER | 17 | +| CANNOT_CREATE_FILE | 18 | +| CANNOT_DELETE_FOLDER | 19 | +| CANNOT_DELETE_FILE | 20 | +| BUILD_INDEX_ERROR | 21 | +| ILLEGAL_NLIST | 22 | +| ILLEGAL_METRIC_TYPE | 23 | +| OUT_OF_MEMORY | 24 | +| PATH_PARAM_LOSS | 31 | +| UNKNOWN_PATH | 32 | +| QUERY_PARAM_LOSS | 33 | +| BODY_FIELD_LOSS | 34 | +| ILLEGAL_BODY | 35 | +| BODY_PARSE_FAIL | 36 | +| ILLEGAL_QUERY_PARAM | 37 |