Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More HTTP examples. #2054

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 110 additions & 2 deletions example/http/create_list_show_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,56 @@ curl --request POST \
]
} '

# insert data
echo -e '\n\n-- insert 4 rows into tbl1'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/docs \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
[
{
"name": "row1",
"score": 3.0,
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.4, 0.3, 0.1],
"fulltext_column" : "random string 1",
"sparse_column": {"10":1.1, "20":2.2, "30": 3.3},
"tensor_column": [[1.0, 0.7, 0.9, 0.8], [1.1, 0.1, 0.3, 0.2]],
"multivector_column" : [[0.1, 0.3, 0.5, 0.7], [0.2, 0.4, 0.6, 0.8]],
"tensorarray_column" : [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0]]]
},
{
"name": "row2",
"score": 2.0,
"dense_column": [1.0, 2.2, 0.56, 1.9, 1.5, 0.2, 0.03, 0.14],
"fulltext_column" : "random string 2",
"sparse_column": {"10":4.1, "20":1.8, "30": 3.4},
"tensor_column": [[1.0, 0.4, 0.3, 0.0], [1.1, 0.5, 0.0, 0.7]],
"multivector_column" : [[0.2, 0.4, 0.6, 0.8], [0.1, 0.3, 0.5, 0.7]],
"tensorarray_column" : [[[0.7, 0.8], [1.4, 0.3]], [[0.5, 0.1]]]
},
{
"name": "row3",
"score": 4.0,
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.7, 0.6, 0.17],
"fulltext_column" : "random string 3",
"sparse_column": {"10":3.1, "20":1.2, "30": 4.3},
"tensor_column": [[1.0, 0.8, 0.5, 0.0], [1.1, 0.7, 0.0, 0.2]],
"multivector_column" : [[0.1, 0.7, 0.4, 0.6], [0.3, 0.5, 0.4, 0.8]],
"tensorarray_column" : [[[1.2, 0.7], [0.4, 0.1]], [[0.5, 0.4]]]
},
{
"name": "row4",
"score": 3.8,
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.4, 0.3, 0.1],
"fulltext_column" : "random string 4",
"sparse_column": {"10":1.4, "20":3.2, "30": 1.3},
"tensor_column": [[1.0, 0.3, 0.7, 0.6], [0.7, 1.4, 0.2, 0.5]],
"multivector_column" : [[0.6, 0.1, 0.4, 0.8], [0.7, 0.8, 0.5, 0.1]],
"tensorarray_column" : [[[1.2, 1.7], [0.6, 0.7]], [[1.3, 1.4]]]
}
] '

# create HNSW index on dense vector column: 'dense_column'
echo -e '\n\n-- create table index: hnsw_index'
curl --request POST \
Expand Down Expand Up @@ -165,8 +215,6 @@ curl --request POST \
"create_option": "ignore_if_exists"
} '



# list table indexes
echo -e '\n\n-- list table indexes: hnsw_index, sparse_index, fulltext_index, bmp_index should be included'
curl --request GET \
Expand Down Expand Up @@ -203,6 +251,66 @@ curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index \
--header 'accept: application/json'

# show table tbl1 hnsw_index segment 0
echo -e '\n\n-- show tbl1 hnsw_index segment 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/hnsw_index/segment/0 \
--header 'accept: application/json'

# show table tbl1 hnsw_index segment 0 chunk 0
echo -e '\n\n-- show tbl1 hnsw_index segment 0 chunk 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/hnsw_index/segment/0/chunk/0 \
--header 'accept: application/json'

# show table tbl1 multi_vector_hnsw_index segment 0
echo -e '\n\n-- show tbl1 multi_vector_hnsw_index segment 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/multi_vector_hnsw_index/segment/0 \
--header 'accept: application/json'

# show table tbl1 multi_vector_hnsw_index segment 0 chunk 0
echo -e '\n\n-- show tbl1 multi_vector_hnsw_index segment 0 chunk 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/multi_vector_hnsw_index/segment/0/chunk/0 \
--header 'accept: application/json'

# show table tbl1 fulltext_index segment 0
echo -e '\n\n-- show tbl1 fulltext_index segment 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/fulltext_index/segment/0 \
--header 'accept: application/json'

# show table tbl1 fulltext_index segment 0 chunk 0
echo -e '\n\n-- show tbl1 fulltext_index segment 0 chunk 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/fulltext_index/segment/0/chunk/0 \
--header 'accept: application/json'

# show table tbl1 secondary_index segment 0
echo -e '\n\n-- show tbl1 secondary_index segment 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/secondary_index/segment/0 \
--header 'accept: application/json'

# show table tbl1 secondary_index segment 0 chunk 0
echo -e '\n\n-- show tbl1 secondary_index segment 0 chunk 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/secondary_index/segment/0/chunk/0 \
--header 'accept: application/json'

# show table tbl1 bmp_index segment 0
echo -e '\n\n-- show tbl1 bmp_index segment 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index/segment/0 \
--header 'accept: application/json'

# show table tbl1 bmp_index segment 0 chunk 0
echo -e '\n\n-- show tbl1 bmp_index segment 0 chunk 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index/segment/0/chunk/0 \
--header 'accept: application/json'

# drop tbl1 hnsw_index
echo -e '\n\n-- drop tbl1 hnsw_index'
curl --request DELETE \
Expand Down
148 changes: 148 additions & 0 deletions example/http/show_metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# create table 'tbl1'
echo -e '-- create tbl1'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1 \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data ' {
"create_option": "ignore_if_exists",
"fields": [
{
"name": "num",
"type": "integer"
},
{
"name": "body",
"type": "varchar"
},
{
"name": "vec",
"type": "vector, 4, float"
},
{
"name": "sparse_column",
"type": "sparse,100,float,int"
},
{
"name": "year",
"type": "integer"
},
{
"name": "tensor",
"type": "tensor,4,float"
}
]
} '

# insert 4 rows into 'tbl1'
echo -e '\n\n-- insert 4 rows into tbl1'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/docs \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
[
{
"num": 1,
"body": "unnecessary and harmful",
"vec": [1.0, 1.2, 0.8, 0.9],
"sparse_column": {"10":1.1, "20":2.2, "30": 3.3},
"year": 2024,
"tensor": [[1.0, 0.0, 0.0, 0.0], [1.1, 0.0, 0.0, 0.0]]
},
{
"num": 2,
"body": "Office for Harmful Blooms",
"vec": [4.0, 4.2, 4.3, 4.5],
"sparse_column": {"40":4.4, "50":5.5, "60": 6.6},
"year": 2023,
"tensor": [[4.0, 0.0, 4.3, 4.5], [4.0, 4.2, 4.4, 5.0]]
},
{
"num": 3,
"body": "A Bloom filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970, that is used to test whether an element is a member of a set.",
"vec": [4.0, 4.2, 4.3, 4.2],
"sparse_column": {"70":7.7, "80":8.8, "90": 9.9},
"year": 2019,
"tensor": [[0.9, 0.1, 0.0, 0.0], [1.1, 0.0, 0.0, 0.0]]
},
{
"num": 4,
"body": "The American Football Conference (AFC) harm chemical anarchism add test is one of harm chemical the two conferences of the National Football League (NFL). This add test conference and its counterpart, the National Football Conference (NFC), currently contain 16 teams each, making up the 32 teams of the NFL. The current AFC title holder is the New England Patriots.",
"vec": [4.0, 4.2, 4.3, 4.5],
"sparse_column": {"20":7.7, "80":7.8, "90": 97.9},
"year": 2018,
"tensor": [[5.0, 4.2, 4.3, 4.5], [4.0, 4.2, 4.3, 4.4]]
}
] '

# list tables, there are 'tbl1' at least.
echo -e '\n-- list tables, tbl1 should be included'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables \
--header 'accept: application/json'

# show table tb1
echo -e '\n-- show tbl1'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1 \
--header 'accept: application/json'

# show table tbl1 segments
echo -e '\n-- show tbl1 segments'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/segments \
--header 'accept: application/json'

# show table tbl1 segment 0 blocks
echo -e '\n-- show tbl1 segment 0 blocks'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks \
--header 'accept: application/json'

# show table tbl1 segment 0 block 0
echo -e '\n-- show tbl1 segment 0 block 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks/0 \
--header 'accept: application/json'

# show table tbl1 segment 0 block 0 column 0
echo -e '\n-- show tbl1 segment 0 block 0 column 0'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks/0/0 \
--header 'accept: application/json'

# show table tb1 columns
echo -e '\n-- show tbl1 columns'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
--header 'accept: application/json'

# drop table column tbl1.year
echo -e '\n-- drop table column tbl1.year'
curl --request DELETE \
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data ' {"column_names": ["year"]} '

# show table tbl1 columns again, tbl1.year will be gone
echo -e '\n-- show tbl1 columns, tbl1.year will be gone'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
--header 'accept: application/json'

# drop tbl1
echo -e '\n-- drop tbl1'
curl --request DELETE \
--url http://localhost:23820/databases/default_db/tables/tbl1 \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data ' {"drop_option": "error"} '

# list tables, 'tbl1' is dropped.
echo -e '\n-- list tables, tbl1 is dropped'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables \
--header 'accept: application/json'
echo -e '\n'