2022-06-20 22:06:12 +08:00
#!/bin/bash
# Exit immediately for non zero status
set -e
# Print commands
set -x
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
SOURCE = " $( readlink " $SOURCE " ) "
[ [ $SOURCE != /* ] ] && SOURCE = " $DIR / $SOURCE " # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
ROOT = " $( cd -P " $( dirname " $SOURCE " ) /../.. " && pwd ) "
DATA_PATH = " ${ ROOT } /tests/scripts/restful-data/ "
MILVUS_CLUSTER_ENABLED = " ${ MILVUS_CLUSTER_ENABLED :- false } "
2022-06-27 11:48:16 +08:00
MILVUS_SERVICE_NAME = $( echo " ${ MILVUS_HELM_RELEASE_NAME } -milvus. ${ MILVUS_HELM_NAMESPACE } " | tr -d '\n' )
MILVUS_SERVICE_ADDRESS = " ${ MILVUS_SERVICE_NAME } :9091 "
2022-06-20 22:06:12 +08:00
# Create a collection
curl -X 'POST' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${ DATA_PATH } /create-collection.json
# Has collection
curl -X 'GET' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection/existence " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book"
} '
# Check collection details
curl -X 'GET' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book"
} '
# Load collection
curl -X 'POST' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection/load " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book"
} '
### Data
# Insert Data
curl -X 'POST' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/entities " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${ DATA_PATH } /insert-data.json
# Build Index
curl -X 'POST' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/index " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book" ,
"field_name" : "book_intro" ,
"extra_params" :[
{ "key" : "metric_type" , "value" : "L2" } ,
{ "key" : "index_type" , "value" : "IVF_FLAT" } ,
{ "key" : "params" , "value" : "{\"nlist\":1024}" }
]
} '
# KNN Search
curl -X 'POST' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/search " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${ DATA_PATH } /search.json
# Drop Index
curl -X 'DELETE' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/index " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book" ,
"field_name" : "book_intro"
} '
# Release collection
curl -X 'DELETE' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection/load " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book"
} '
# Drop collection
curl -X 'DELETE' \
2022-06-24 15:34:14 +08:00
" http:// ${ MILVUS_SERVICE_ADDRESS } /api/v1/collection " \
2022-06-20 22:06:12 +08:00
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"collection_name" : "book"
} '