mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
Params in Restful-api is different from the params in other SDKs (#3926)
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>
This commit is contained in:
parent
442b8d6512
commit
869fb7ae77
@ -79,6 +79,7 @@ Please mark all changes in change log and use the issue from GitHub
|
||||
- \#3449 Upgrade master version to v0.11.0
|
||||
- \#3465 Optimize gc event executor
|
||||
- \#3631 Add build option `-rdynamic` in CMakeList.txt
|
||||
- \#3882 Params in Restful-api is different from the params in other SDKs
|
||||
|
||||
## Task
|
||||
|
||||
|
||||
@ -6,12 +6,6 @@
|
||||
- [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)
|
||||
- [`/collections` (GET)](#collections-get)
|
||||
- [`/collections` (POST)](#collections-post)
|
||||
- [`/collections` (OPTIONS)](#collections-options)
|
||||
@ -106,242 +100,6 @@ $ curl -X GET "http://127.0.0.1:19121/devices" -H "accept: application/json"
|
||||
|
||||
##### Response
|
||||
|
||||
```json
|
||||
{ "cpu": { "memory": 31 }, "gpus": { "GPU0": { "memory": 5 } } }
|
||||
```
|
||||
|
||||
### `/config/advanced` (GET)
|
||||
|
||||
Gets the values of parameters in `cache_config` and `engine_config` of the Milvus configuration file.
|
||||
|
||||
#### Request
|
||||
|
||||
| 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. |
|
||||
|
||||
#### Example
|
||||
|
||||
##### Request
|
||||
|
||||
```shell
|
||||
$ 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
|
||||
}
|
||||
```
|
||||
|
||||
### `/config/advanced` (PUT)
|
||||
|
||||
Updates the values of parameters in `cache_config` and `engine_config` of the Milvus configuration file.
|
||||
|
||||
#### Request
|
||||
|
||||
<table>
|
||||
<tr><th>Request Component</th><th>Value</th></tr>
|
||||
<tr><td> Name</td><td><pre><code>/config/advanced</code></pre></td></tr>
|
||||
<tr><td>Header </td><td><pre><code>accept: application/json</code></pre> </td></tr>
|
||||
<tr><td>Body</td><td><pre><code>
|
||||
{
|
||||
"cpu_cache_capacity": integer($int64),
|
||||
"cache_insert_data": boolean,
|
||||
"use_blas_threshold": integer($int64),
|
||||
"gpu_search_threshold": integer($int64)
|
||||
}
|
||||
</code></pre> </td></tr>
|
||||
<tr><td>Method</td><td>PUT</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
> Note: `gpu_search_config` is available only in GPU-supported Milvus.
|
||||
|
||||
##### 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 |
|
||||
|
||||
#### 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/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 }
|
||||
```
|
||||
|
||||
### `/config/advanced` (OPTIONS)
|
||||
|
||||
Use this API for Cross-Origin Resource Sharing (CORS).
|
||||
|
||||
#### Request
|
||||
|
||||
| Request Component | Value |
|
||||
| ----------------- | ------------------ |
|
||||
| Name | `/config/advanced` |
|
||||
| Header | N/A |
|
||||
| Body | N/A |
|
||||
| Method | OPTIONS |
|
||||
|
||||
#### Example
|
||||
|
||||
##### Request
|
||||
|
||||
```shell
|
||||
$ curl -X OPTIONS "http://127.0.0.1:19121/config/advanced"
|
||||
```
|
||||
|
||||
### `/config/gpu_resources` (GET)
|
||||
|
||||
Gets the parameter values in `gpu_resource_config` of the Milvus configuration file.
|
||||
|
||||
> Note: This method is available only for GPU-supported Milvus.
|
||||
|
||||
#### Request
|
||||
|
||||
| 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. |
|
||||
|
||||
#### Example
|
||||
|
||||
##### Request
|
||||
|
||||
```shell
|
||||
$ 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"]
|
||||
}
|
||||
```
|
||||
|
||||
### `/config/gpu_resources` (PUT)
|
||||
|
||||
Updates the parameter values in `gpu_resource_config` of the Milvus configuration file.
|
||||
|
||||
> Note: This method is available only for GPU-supported Milvus.
|
||||
|
||||
#### Request
|
||||
|
||||
<table>
|
||||
<tr><th>Request Component</th><th>Value</th></tr>
|
||||
<tr><td> Name</td><td><pre><code>/config/gpu_resources</code></pre></td></tr>
|
||||
<tr><td>Header </td><td><pre><code>accept: application/json</code></pre> </td></tr>
|
||||
<tr><td>Body</td><td><pre><code>
|
||||
{
|
||||
"enable": boolean,
|
||||
"cache_capacity": integer($int64),
|
||||
"search_resources": [string],
|
||||
"build_index_resources": [string]
|
||||
}
|
||||
</code></pre> </td></tr>
|
||||
<tr><td>Method</td><td>PUT</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
##### 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 |
|
||||
|
||||
#### 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/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 }
|
||||
```
|
||||
|
||||
### `/config/gpu_resources` (OPTIONS)
|
||||
|
||||
Use this API for Cross-Origin Resource Sharing (CORS).
|
||||
|
||||
> Note: This method is available only for GPU-supported Milvus.
|
||||
|
||||
#### Request
|
||||
|
||||
| Request Component | Value |
|
||||
| ----------------- | ----------------------- |
|
||||
| Name | `/config/gpu_resources` |
|
||||
| Header | N/A |
|
||||
| Body | N/A |
|
||||
| Method | OPTIONS |
|
||||
|
||||
#### Example
|
||||
|
||||
##### Request
|
||||
|
||||
```shell
|
||||
$ curl -X OPTIONS "http://127.0.0.1:19121/config/gpu_resources"
|
||||
```
|
||||
|
||||
### `/collections` (GET)
|
||||
|
||||
Gets all collections starting from `offset` and ends with `page_size`.
|
||||
@ -381,21 +139,25 @@ $ curl -X GET "http://127.0.0.1:19121/collections?offset=0&page_size=1" -H "acce
|
||||
|
||||
```json
|
||||
{
|
||||
"collections": [
|
||||
{
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dimension": 128, "metric_type": "L2"}
|
||||
}
|
||||
],
|
||||
"segment_size": 1024
|
||||
}
|
||||
],
|
||||
"count": 58
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"collections": [
|
||||
{
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"params": {"dime": 128}
|
||||
}
|
||||
],
|
||||
"segment_size": 1024,
|
||||
"auto_id": true
|
||||
}
|
||||
],
|
||||
"total": 58
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -414,12 +176,13 @@ Creates a collection.
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dimension": 128, "metric_type": "L2"}
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"params": {"dim": 128}
|
||||
}
|
||||
]
|
||||
],
|
||||
"segment_row_limit": 10000,
|
||||
"auto_id": true
|
||||
}
|
||||
</code></pre> </td></tr>
|
||||
<tr><td>Method</td><td>POST</td></tr>
|
||||
@ -431,9 +194,7 @@ Creates a collection.
|
||||
| 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. | No |
|
||||
| `fields` | The fields of a collections. | Yes |
|
||||
|
||||
* Currently supported metrics include:
|
||||
- `L2` (Euclidean distance),
|
||||
@ -528,16 +289,18 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection" -H "accept: a
|
||||
{
|
||||
"code": 0,
|
||||
"message":"OK",
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dimension": 128, "metric_type": "L2"}
|
||||
}
|
||||
],
|
||||
"row_count": 10000
|
||||
"data": {
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"params": {"dimension": 128, "metric_type": "L2"}
|
||||
}
|
||||
],
|
||||
"row_count": 10000
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -551,21 +314,24 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection?info=stat" -H
|
||||
|
||||
```json
|
||||
{
|
||||
"partitions":[
|
||||
{
|
||||
"row_count":10000,
|
||||
"segments":[
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"partitions":[
|
||||
{
|
||||
"data_size":5284922,
|
||||
"index_name":"IVFFLAT",
|
||||
"name":"1589468453228582000",
|
||||
"row_count":10000
|
||||
"row_count":10000,
|
||||
"segments":[
|
||||
{
|
||||
"data_size":5284922,
|
||||
"name":"1589468453228582000",
|
||||
"row_count":10000
|
||||
}
|
||||
],
|
||||
"tag":"_default"
|
||||
}
|
||||
],
|
||||
"tag":"_default"
|
||||
}
|
||||
],
|
||||
"row_count":10000
|
||||
"row_count":10000
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
@ -693,7 +459,7 @@ $ curl -X POST "http://127.0.0.1:19121/collections/test_collection/indexes" -H "
|
||||
{ "message": "OK", "code": 0 }
|
||||
```
|
||||
|
||||
### `/collections/{collection_name}/fields/{field_name}/indexes/{index_name}` (DELETE)
|
||||
### `/collections/{collection_name}/fields/{field_name}/indexes` (DELETE)
|
||||
|
||||
Drops an index for a collection.
|
||||
|
||||
@ -798,12 +564,16 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/partitions?off
|
||||
|
||||
```json
|
||||
{
|
||||
"partitions": [
|
||||
{ "partition_tag": "_default" },
|
||||
{ "partition_tag": "test_tag" },
|
||||
{ "partition_tag": "test_2" }
|
||||
],
|
||||
"count": 10
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"partitions": [
|
||||
{ "partition_tag": "_default" },
|
||||
{ "partition_tag": "test_tag" },
|
||||
{ "partition_tag": "test_2" }
|
||||
],
|
||||
"total": 10
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -892,7 +662,7 @@ Deletes a partition by tag.
|
||||
|
||||
| Parameter | Description | Required? |
|
||||
| ----------------- | --------------------------------------------------- | --------- |
|
||||
| `collection_name` | Name of the collection that contains the partition. | Yes |
|
||||
| `collection_name` | Name of the collection that contains the partition. | yes |
|
||||
| `partition_tag` | Tag of the partition to delete. | yes |
|
||||
|
||||
#### Response
|
||||
@ -918,18 +688,22 @@ The deletion is successful if no information is returned.
|
||||
|
||||
```json
|
||||
{
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -977,7 +751,7 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/15837
|
||||
```json
|
||||
{
|
||||
"ids": ["1583727470435045000"],
|
||||
"count": 10000
|
||||
"total": 10000
|
||||
}
|
||||
```
|
||||
|
||||
@ -999,7 +773,9 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/15837
|
||||
{"vector":
|
||||
{
|
||||
"field_vec": {
|
||||
"nprobe": 64,
|
||||
"params": {
|
||||
"nprobe": 64
|
||||
}
|
||||
"topk": 100,
|
||||
"metric_type": "L2"
|
||||
"values": [
|
||||
@ -1010,12 +786,12 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/15837
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
"fields": ["field_vec"]
|
||||
},
|
||||
"fields": ["field_vec"]
|
||||
}
|
||||
}
|
||||
</code></pre> </td></tr>
|
||||
<tr><td>Method</td><td>PUT</td></tr>
|
||||
<tr><td>Method</td><td>GET</td></tr>
|
||||
</table>
|
||||
|
||||
##### Body Parameters
|
||||
@ -1053,29 +829,33 @@ $ curl -X PUT "http://127.0.0.1:19121/collections/test_collection/entities" -H "
|
||||
|
||||
```json
|
||||
{
|
||||
"num": 2,
|
||||
"result": [
|
||||
[
|
||||
{
|
||||
"id": "1578989029645098000",
|
||||
"distance": "0.000000",
|
||||
"entity": {
|
||||
"field_1": 1,
|
||||
"field_2": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1578989029645098001",
|
||||
"distance": "0.010000",
|
||||
"entity": {
|
||||
"field_1": 10,
|
||||
"field_2": 20,
|
||||
"field_vec": []
|
||||
}
|
||||
}
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"num": 2,
|
||||
"result": [
|
||||
[
|
||||
{
|
||||
"id": "1578989029645098000",
|
||||
"distance": "0.000000",
|
||||
"entity": {
|
||||
"field_1": 1,
|
||||
"field_2": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1578989029645098001",
|
||||
"distance": "0.010000",
|
||||
"entity": {
|
||||
"field_1": 10,
|
||||
"field_2": 20,
|
||||
"field_vec": []
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -1117,18 +897,22 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/entities?ids=1
|
||||
|
||||
```json
|
||||
{
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -1171,18 +955,22 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/entities?page_
|
||||
|
||||
```json
|
||||
{
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"data": {
|
||||
"entities": [
|
||||
{
|
||||
"__id": "1578989029645098000",
|
||||
"field_1": 1,
|
||||
"field_vec": []
|
||||
},
|
||||
{
|
||||
"__id": "1578989029645098001",
|
||||
"field_1": 2,
|
||||
"field_vec": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -1198,12 +986,10 @@ Delete entities
|
||||
<tr><td>Header </td><td><pre><code>accept: application/json</code></pre> </td></tr>
|
||||
<tr><td>Body</td><td><pre><code>
|
||||
{
|
||||
"delete": {
|
||||
"ids": [$string]
|
||||
}
|
||||
"ids": [$string]
|
||||
}
|
||||
</code></pre> </td></tr>
|
||||
<tr><td>Method</td><td>PUT</td></tr>
|
||||
<tr><td>Method</td><td>DELETE</td></tr>
|
||||
</table>
|
||||
|
||||
##### Body Parameters
|
||||
@ -1257,7 +1043,7 @@ Inserts entities to a collection.
|
||||
"partition_tag": "part",
|
||||
"entities": {
|
||||
"__id": [123456789,234567]
|
||||
"field_1": [1, 2]
|
||||
"field_1": 1
|
||||
"field_vec": [[], []]
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,10 +508,11 @@ class WebController : public oatpp::web::server::api::ApiController {
|
||||
auto handler = WebRequestHandler();
|
||||
|
||||
std::shared_ptr<OutgoingResponse> response;
|
||||
auto status_dto = handler.ShowPartitions(collection_name, query_params, partition_list_dto);
|
||||
String result;
|
||||
auto status_dto = handler.ShowPartitions(collection_name, query_params, result);
|
||||
switch (*(status_dto->code)) {
|
||||
case StatusCode::SUCCESS:
|
||||
response = createDtoResponse(Status::CODE_200, partition_list_dto);
|
||||
response = createResponse(Status::CODE_200, result);
|
||||
break;
|
||||
case StatusCode::COLLECTION_NOT_EXISTS:
|
||||
response = createDtoResponse(Status::CODE_404, status_dto);
|
||||
@ -558,9 +559,15 @@ class WebController : public oatpp::web::server::api::ApiController {
|
||||
ADD_DEFAULT_CORS(EntityOp)
|
||||
|
||||
ENDPOINT("GET", "/collections/{collection_name}/entities", EntityOp, PATH(String, collection_name),
|
||||
QUERIES(QueryParams, query_params), BODY_STRING(String, body_str)) {
|
||||
auto handler = WebRequestHandler();
|
||||
QUERIES(QueryParams, query_params), REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
String body_str;
|
||||
try {
|
||||
body_str = request->readBodyToString();
|
||||
} catch (...) {
|
||||
body_str = "";
|
||||
}
|
||||
|
||||
auto handler = WebRequestHandler();
|
||||
String response;
|
||||
auto status_dto = handler.EntityOp(collection_name, query_params, body_str, response);
|
||||
switch (*(status_dto->code)) {
|
||||
|
||||
@ -290,25 +290,27 @@ WebRequestHandler::GetCollectionMetaInfo(const std::string& collection_name, nlo
|
||||
int64_t count;
|
||||
STATUS_CHECK(req_handler_.CountEntities(context_ptr_, collection_name, count));
|
||||
|
||||
json_out["collection_name"] = schema.collection_name_;
|
||||
nlohmann::json result_json;
|
||||
result_json["collection_name"] = schema.collection_name_;
|
||||
for (const auto& field : schema.fields_) {
|
||||
if (field.first == engine::FIELD_UID) {
|
||||
continue;
|
||||
}
|
||||
nlohmann::json field_json;
|
||||
field_json["field_name"] = field.first;
|
||||
field_json["field_type"] = type2str.at(field.second.field_type_);
|
||||
field_json["name"] = field.first;
|
||||
field_json["type"] = type2str.at(field.second.field_type_);
|
||||
field_json["index_params"] = field.second.index_params_;
|
||||
field_json["extra_params"] = field.second.field_params_;
|
||||
json_out["fields"].push_back(field_json);
|
||||
field_json["params"] = field.second.field_params_;
|
||||
result_json["fields"].push_back(field_json);
|
||||
}
|
||||
if (schema.extra_params_.contains(engine::PARAM_SEGMENT_ROW_COUNT)) {
|
||||
json_out[engine::PARAM_SEGMENT_ROW_COUNT] = schema.extra_params_[engine::PARAM_SEGMENT_ROW_COUNT];
|
||||
result_json[engine::PARAM_SEGMENT_ROW_COUNT] = schema.extra_params_[engine::PARAM_SEGMENT_ROW_COUNT];
|
||||
}
|
||||
if (schema.extra_params_.contains(engine::PARAM_UID_AUTOGEN)) {
|
||||
json_out[engine::PARAM_UID_AUTOGEN] = schema.extra_params_[engine::PARAM_UID_AUTOGEN];
|
||||
result_json[engine::PARAM_UID_AUTOGEN] = schema.extra_params_[engine::PARAM_UID_AUTOGEN];
|
||||
}
|
||||
json_out["count"] = count;
|
||||
result_json["count"] = count;
|
||||
json_out["data"] = result_json;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -319,7 +321,7 @@ WebRequestHandler::GetCollectionStat(const std::string& collection_name, nlohman
|
||||
|
||||
if (status.ok()) {
|
||||
try {
|
||||
json_out = nlohmann::json::parse(collection_stats);
|
||||
json_out["data"] = nlohmann::json::parse(collection_stats);
|
||||
} catch (std::exception& e) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR,
|
||||
"Error occurred when parsing collection stat information: " + std::string(e.what()));
|
||||
@ -364,7 +366,7 @@ WebRequestHandler::GetPageEntities(const std::string& collection_name, const std
|
||||
}
|
||||
}
|
||||
}
|
||||
json_out["count"] = row_count;
|
||||
json_out["total"] = row_count;
|
||||
int64_t real_offset = entity_num;
|
||||
int64_t real_page_size = page_size;
|
||||
|
||||
@ -411,7 +413,7 @@ WebRequestHandler::GetSegmentVectors(const std::string& collection_name, int64_t
|
||||
} else {
|
||||
json_out["vectors"] = vectors_json;
|
||||
}
|
||||
json_out["count"] = vector_ids.size();
|
||||
json_out["total"] = vector_ids.size();
|
||||
|
||||
// AddStatusToJson(json_out, status.code(), status.message());
|
||||
|
||||
@ -434,7 +436,7 @@ WebRequestHandler::GetSegmentIds(const std::string& collection_name, int64_t seg
|
||||
json_out["ids"].push_back(std::to_string(ids.at(i)));
|
||||
}
|
||||
}
|
||||
json_out["count"] = ids.size();
|
||||
json_out["total"] = ids.size();
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -1250,16 +1252,16 @@ WebRequestHandler::CreateCollection(const milvus::server::web::OString& body) {
|
||||
std::unordered_map<std::string, FieldSchema> fields;
|
||||
for (auto& field : json_str["fields"]) {
|
||||
FieldSchema field_schema;
|
||||
std::string field_name = field["field_name"];
|
||||
std::string field_name = field["name"];
|
||||
|
||||
if (fields.find(field_name) != fields.end()) {
|
||||
auto status = Status(SERVER_INVALID_FIELD_NAME, "Collection mapping has duplicate field names");
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
field_schema.field_params_ = field["extra_params"];
|
||||
field_schema.field_params_ = field["params"];
|
||||
|
||||
std::string field_type = field["field_type"];
|
||||
std::string field_type = field["type"];
|
||||
std::transform(field_type.begin(), field_type.end(), field_type.begin(), ::tolower);
|
||||
|
||||
if (str2type.find(field_type) == str2type.end()) {
|
||||
@ -1333,11 +1335,11 @@ WebRequestHandler::ShowCollections(const OQueryParams& query_params, OString& re
|
||||
}
|
||||
|
||||
nlohmann::json result_json;
|
||||
result_json["count"] = collections.size();
|
||||
result_json["data"]["total"] = collections.size();
|
||||
if (collections_json.empty()) {
|
||||
result_json["collections"] = std::vector<int64_t>();
|
||||
result_json["data"]["collections"] = std::vector<int64_t>();
|
||||
} else {
|
||||
result_json["collections"] = collections_json;
|
||||
result_json["data"]["collections"] = collections_json;
|
||||
}
|
||||
|
||||
AddStatusToJson(result_json, status.code(), status.message());
|
||||
@ -1422,7 +1424,7 @@ WebRequestHandler::CreatePartition(const OString& collection_name, const Partiti
|
||||
|
||||
StatusDtoT
|
||||
WebRequestHandler::ShowPartitions(const OString& collection_name, const OQueryParams& query_params,
|
||||
PartitionListDtoT& partition_list_dto) {
|
||||
OString& result_str) {
|
||||
int64_t offset = 0;
|
||||
auto status = ParseQueryInteger(query_params, "offset", offset);
|
||||
if (!status.ok()) {
|
||||
@ -1464,17 +1466,21 @@ WebRequestHandler::ShowPartitions(const OString& collection_name, const OQueryPa
|
||||
page_size = std::min(partition_names.size() - offset, static_cast<size_t>(page_size));
|
||||
}
|
||||
|
||||
partition_list_dto->count = partition_names.size();
|
||||
partition_list_dto->partitions = partition_list_dto->partitions.createShared();
|
||||
milvus::json data_json;
|
||||
data_json["total"] = partition_names.size();
|
||||
|
||||
if (offset < static_cast<int64_t>(partition_names.size())) {
|
||||
for (int64_t i = offset; i < page_size + offset; i++) {
|
||||
auto partition_dto = PartitionFieldsDto::createShared();
|
||||
partition_dto->partition_tag = partition_names.at(i).c_str();
|
||||
partition_list_dto->partitions->push_back(partition_dto);
|
||||
milvus::json partition_json;
|
||||
partition_json["partition_tag"] = partition_names.at(i).c_str();
|
||||
data_json["partitions"].push_back(partition_json);
|
||||
}
|
||||
}
|
||||
|
||||
milvus::json result_json;
|
||||
result_json["data"] = data_json;
|
||||
AddStatusToJson(result_json, status.code(), status.message());
|
||||
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
@ -1565,7 +1571,7 @@ WebRequestHandler::ShowSegments(const OString& collection_name, const OQueryPara
|
||||
} else {
|
||||
result_json["segments"] = segments_json;
|
||||
}
|
||||
result_json["count"] = segments_json.size();
|
||||
result_json["total"] = segments_json.size();
|
||||
AddStatusToJson(result_json, status.code(), status.message());
|
||||
response = result_json.dump().c_str();
|
||||
|
||||
@ -1724,7 +1730,7 @@ WebRequestHandler::GetEntity(const milvus::server::web::OString& collection_name
|
||||
}
|
||||
status = GetPageEntities(collection_name->std_str(), partition_tag, page_size, offset, json_out);
|
||||
if (!status.ok()) {
|
||||
json_out["entities"] = json::array();
|
||||
json_out["data"]["entities"] = json::array();
|
||||
}
|
||||
AddStatusToJson(json_out, status.code(), status.message());
|
||||
response = json_out.dump().c_str();
|
||||
@ -1752,21 +1758,23 @@ WebRequestHandler::GetEntity(const milvus::server::web::OString& collection_name
|
||||
}
|
||||
|
||||
std::vector<bool> valid_row;
|
||||
nlohmann::json entity_result_json;
|
||||
milvus::json entity_result_json;
|
||||
status = GetEntityByIDs(collection_name->std_str(), entity_ids, field_names, entity_result_json);
|
||||
if (!status.ok()) {
|
||||
response = "NULL";
|
||||
return status;
|
||||
}
|
||||
|
||||
nlohmann::json json;
|
||||
AddStatusToJson(json, status.code(), status.message());
|
||||
milvus::json data_json;
|
||||
milvus::json json;
|
||||
AddStatusToJson(data_json, status.code(), status.message());
|
||||
if (entity_result_json.empty()) {
|
||||
json = std::vector<int64_t>();
|
||||
} else {
|
||||
json = entity_result_json;
|
||||
}
|
||||
response = json.dump().c_str();
|
||||
data_json["data"] = json;
|
||||
response = data_json.dump().c_str();
|
||||
} catch (std::exception& e) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, e.what());
|
||||
}
|
||||
|
||||
@ -195,8 +195,7 @@ class WebRequestHandler {
|
||||
CreatePartition(const OString& collection_name, const PartitionRequestDtoT& param);
|
||||
|
||||
StatusDtoT
|
||||
ShowPartitions(const OString& collection_name, const OQueryParams& query_params,
|
||||
PartitionListDtoT& partition_list_dto);
|
||||
ShowPartitions(const OString& collection_name, const OQueryParams& query_params, OString& response);
|
||||
|
||||
StatusDtoT
|
||||
DropPartition(const OString& collection_name, const OString& body);
|
||||
|
||||
@ -420,16 +420,14 @@ CreateCollection(const TestClientP& client_ptr, const TestConnP& connection_ptr,
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dim": 128}
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"params": {"dim": 128}
|
||||
},
|
||||
{
|
||||
"field_name": "int64",
|
||||
"field_type": "int64",
|
||||
"index_params": {},
|
||||
"extra_params": {}
|
||||
"name": "int64",
|
||||
"type": "int64",
|
||||
"params": {}
|
||||
}
|
||||
],
|
||||
"segment_row_count": 100000
|
||||
@ -510,16 +508,14 @@ TEST_F(WebControllerTest, CREATE_COLLECTION) {
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dim": 128}
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"params": {"dim": 128}
|
||||
},
|
||||
{
|
||||
"field_name": "int64",
|
||||
"field_type": "int64",
|
||||
"index_params": {},
|
||||
"extra_params": {}
|
||||
"name": "int64",
|
||||
"type": "int64",
|
||||
"params": {}
|
||||
}
|
||||
]
|
||||
})";
|
||||
@ -539,8 +535,8 @@ TEST_F(WebControllerTest, GET_COLLECTION_INFO) {
|
||||
auto response = client_ptr->getCollection(collection_name.c_str(), connection_ptr);
|
||||
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode());
|
||||
auto json_response = nlohmann::json::parse(response->readBodyToString()->c_str());
|
||||
ASSERT_EQ(collection_name, json_response["collection_name"]);
|
||||
ASSERT_EQ(2, json_response["fields"].size());
|
||||
ASSERT_EQ(collection_name, json_response["data"]["collection_name"]);
|
||||
ASSERT_EQ(2, json_response["data"]["fields"].size());
|
||||
|
||||
// invalid collection name
|
||||
collection_name = "57474dgdfhdfhdh dgd";
|
||||
@ -554,7 +550,7 @@ TEST_F(WebControllerTest, SHOW_COLLECTIONS) {
|
||||
auto response = client_ptr->showCollections("1", "1", connection_ptr);
|
||||
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode());
|
||||
auto json_response = nlohmann::json::parse(response->readBodyToString()->std_str());
|
||||
ASSERT_GE(json_response["count"].get<int64_t>(), 0);
|
||||
ASSERT_GE(json_response["data"]["total"].get<int64_t>(), 0);
|
||||
|
||||
// test query collection empty
|
||||
response = client_ptr->showCollections("0", "0", connection_ptr);
|
||||
@ -623,16 +619,14 @@ TEST_F(WebControllerTest, INSERT_BIN) {
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_BINARY",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dim": 128}
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_BINARY",
|
||||
"params": {"dim": 128}
|
||||
},
|
||||
{
|
||||
"field_name": "int64",
|
||||
"field_type": "int64",
|
||||
"index_params": {},
|
||||
"extra_params": {}
|
||||
"name": "int64",
|
||||
"type": "int64",
|
||||
"params": {}
|
||||
}
|
||||
],
|
||||
"segment_row_count": 100000,
|
||||
@ -774,16 +768,14 @@ TEST_F(WebControllerTest, SEARCH) {
|
||||
"collection_name": "test_collection",
|
||||
"fields": [
|
||||
{
|
||||
"field_name": "field_vec",
|
||||
"field_type": "VECTOR_FLOAT",
|
||||
"index_params": {"name": "index_1", "index_type": "IVFFLAT", "nlist": 4096},
|
||||
"extra_params": {"dim": 4}
|
||||
"name": "field_vec",
|
||||
"type": "VECTOR_FLOAT",
|
||||
"params": {"dim": 4}
|
||||
},
|
||||
{
|
||||
"field_name": "int64",
|
||||
"field_type": "int64",
|
||||
"index_params": {},
|
||||
"extra_params": {}
|
||||
"name": "int64",
|
||||
"type": "int64",
|
||||
"params": {}
|
||||
}
|
||||
],
|
||||
"segment_row_count": 100000
|
||||
@ -871,7 +863,7 @@ TEST_F(WebControllerTest, INDEX) {
|
||||
nlohmann::json collection_json = nlohmann::json::parse(response->readBodyToString()->std_str());
|
||||
std::cout << collection_json.dump() << std::endl;
|
||||
for (const auto& field_json : collection_json["fields"]) {
|
||||
if (field_json["field_name"] == "field_vec") {
|
||||
if (field_json["name"] == "field_vec") {
|
||||
nlohmann::json index_params = field_json["index_params"];
|
||||
ASSERT_EQ(index_params["index_type"].get<std::string>(), milvus::knowhere::IndexEnum::INDEX_FAISS_IVFFLAT);
|
||||
break;
|
||||
|
||||
@ -80,7 +80,6 @@ void
|
||||
ClientTest::CreateCollection(const std::string& collection_name) {
|
||||
milvus::FieldPtr field_ptr1 = std::make_shared<milvus::Field>();
|
||||
milvus::FieldPtr field_ptr2 = std::make_shared<milvus::Field>();
|
||||
milvus::FieldPtr field_ptr3 = std::make_shared<milvus::Field>();
|
||||
milvus::FieldPtr field_ptr4 = std::make_shared<milvus::Field>();
|
||||
|
||||
field_ptr1->field_name = "field_1";
|
||||
@ -95,12 +94,6 @@ ClientTest::CreateCollection(const std::string& collection_name) {
|
||||
index_param_2["name"] = "index_2";
|
||||
field_ptr2->index_params = index_param_2.dump();
|
||||
|
||||
field_ptr3->field_name = "field_3";
|
||||
field_ptr3->field_type = milvus::DataType::INT32;
|
||||
JSON index_param_3;
|
||||
index_param_3["name"] = "index_3";
|
||||
field_ptr3->index_params = index_param_3.dump();
|
||||
|
||||
field_ptr4->field_name = "field_vec";
|
||||
field_ptr4->field_type = milvus::DataType::VECTOR_FLOAT;
|
||||
JSON index_param_4;
|
||||
@ -113,7 +106,7 @@ ClientTest::CreateCollection(const std::string& collection_name) {
|
||||
JSON extra_params;
|
||||
extra_params["segment_row_limit"] = 10000;
|
||||
extra_params["auto_id"] = false;
|
||||
milvus::Mapping mapping = {collection_name, {field_ptr1, field_ptr2, field_ptr3, field_ptr4}};
|
||||
milvus::Mapping mapping = {collection_name, {field_ptr1, field_ptr2, field_ptr4}};
|
||||
|
||||
milvus::Status stat = conn_->CreateCollection(mapping, extra_params.dump());
|
||||
std::cout << "CreateCollection function call status: " << stat.message() << std::endl;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user