Skip to content

Commit 92eab12

Browse files
authored
More HTTP examples. (#2054)
### What problem does this PR solve? New HTTP examples: - Show table segments - Show table blocks - Drop table columns - Show index segments - Show index chunk - Show table block - Show table block block column Issue link: #1937 ### Type of change - [x] Other (please describe): examples change.
1 parent ef11f63 commit 92eab12

File tree

2 files changed

+258
-2
lines changed

2 files changed

+258
-2
lines changed

example/http/create_list_show_index.sh

+110-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,56 @@ curl --request POST \
6363
]
6464
} '
6565

66+
# insert data
67+
echo -e '\n\n-- insert 4 rows into tbl1'
68+
curl --request POST \
69+
--url http://localhost:23820/databases/default_db/tables/tbl1/docs \
70+
--header 'accept: application/json' \
71+
--header 'content-type: application/json' \
72+
--data '
73+
[
74+
{
75+
"name": "row1",
76+
"score": 3.0,
77+
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.4, 0.3, 0.1],
78+
"fulltext_column" : "random string 1",
79+
"sparse_column": {"10":1.1, "20":2.2, "30": 3.3},
80+
"tensor_column": [[1.0, 0.7, 0.9, 0.8], [1.1, 0.1, 0.3, 0.2]],
81+
"multivector_column" : [[0.1, 0.3, 0.5, 0.7], [0.2, 0.4, 0.6, 0.8]],
82+
"tensorarray_column" : [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0]]]
83+
},
84+
{
85+
"name": "row2",
86+
"score": 2.0,
87+
"dense_column": [1.0, 2.2, 0.56, 1.9, 1.5, 0.2, 0.03, 0.14],
88+
"fulltext_column" : "random string 2",
89+
"sparse_column": {"10":4.1, "20":1.8, "30": 3.4},
90+
"tensor_column": [[1.0, 0.4, 0.3, 0.0], [1.1, 0.5, 0.0, 0.7]],
91+
"multivector_column" : [[0.2, 0.4, 0.6, 0.8], [0.1, 0.3, 0.5, 0.7]],
92+
"tensorarray_column" : [[[0.7, 0.8], [1.4, 0.3]], [[0.5, 0.1]]]
93+
},
94+
{
95+
"name": "row3",
96+
"score": 4.0,
97+
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.7, 0.6, 0.17],
98+
"fulltext_column" : "random string 3",
99+
"sparse_column": {"10":3.1, "20":1.2, "30": 4.3},
100+
"tensor_column": [[1.0, 0.8, 0.5, 0.0], [1.1, 0.7, 0.0, 0.2]],
101+
"multivector_column" : [[0.1, 0.7, 0.4, 0.6], [0.3, 0.5, 0.4, 0.8]],
102+
"tensorarray_column" : [[[1.2, 0.7], [0.4, 0.1]], [[0.5, 0.4]]]
103+
},
104+
{
105+
"name": "row4",
106+
"score": 3.8,
107+
"dense_column": [1.0, 1.2, 0.8, 0.9, 0.5, 0.4, 0.3, 0.1],
108+
"fulltext_column" : "random string 4",
109+
"sparse_column": {"10":1.4, "20":3.2, "30": 1.3},
110+
"tensor_column": [[1.0, 0.3, 0.7, 0.6], [0.7, 1.4, 0.2, 0.5]],
111+
"multivector_column" : [[0.6, 0.1, 0.4, 0.8], [0.7, 0.8, 0.5, 0.1]],
112+
"tensorarray_column" : [[[1.2, 1.7], [0.6, 0.7]], [[1.3, 1.4]]]
113+
}
114+
] '
115+
66116
# create HNSW index on dense vector column: 'dense_column'
67117
echo -e '\n\n-- create table index: hnsw_index'
68118
curl --request POST \
@@ -165,8 +215,6 @@ curl --request POST \
165215
"create_option": "ignore_if_exists"
166216
} '
167217

168-
169-
170218
# list table indexes
171219
echo -e '\n\n-- list table indexes: hnsw_index, sparse_index, fulltext_index, bmp_index should be included'
172220
curl --request GET \
@@ -203,6 +251,66 @@ curl --request GET \
203251
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index \
204252
--header 'accept: application/json'
205253

254+
# show table tbl1 hnsw_index segment 0
255+
echo -e '\n\n-- show tbl1 hnsw_index segment 0'
256+
curl --request GET \
257+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/hnsw_index/segment/0 \
258+
--header 'accept: application/json'
259+
260+
# show table tbl1 hnsw_index segment 0 chunk 0
261+
echo -e '\n\n-- show tbl1 hnsw_index segment 0 chunk 0'
262+
curl --request GET \
263+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/hnsw_index/segment/0/chunk/0 \
264+
--header 'accept: application/json'
265+
266+
# show table tbl1 multi_vector_hnsw_index segment 0
267+
echo -e '\n\n-- show tbl1 multi_vector_hnsw_index segment 0'
268+
curl --request GET \
269+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/multi_vector_hnsw_index/segment/0 \
270+
--header 'accept: application/json'
271+
272+
# show table tbl1 multi_vector_hnsw_index segment 0 chunk 0
273+
echo -e '\n\n-- show tbl1 multi_vector_hnsw_index segment 0 chunk 0'
274+
curl --request GET \
275+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/multi_vector_hnsw_index/segment/0/chunk/0 \
276+
--header 'accept: application/json'
277+
278+
# show table tbl1 fulltext_index segment 0
279+
echo -e '\n\n-- show tbl1 fulltext_index segment 0'
280+
curl --request GET \
281+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/fulltext_index/segment/0 \
282+
--header 'accept: application/json'
283+
284+
# show table tbl1 fulltext_index segment 0 chunk 0
285+
echo -e '\n\n-- show tbl1 fulltext_index segment 0 chunk 0'
286+
curl --request GET \
287+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/fulltext_index/segment/0/chunk/0 \
288+
--header 'accept: application/json'
289+
290+
# show table tbl1 secondary_index segment 0
291+
echo -e '\n\n-- show tbl1 secondary_index segment 0'
292+
curl --request GET \
293+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/secondary_index/segment/0 \
294+
--header 'accept: application/json'
295+
296+
# show table tbl1 secondary_index segment 0 chunk 0
297+
echo -e '\n\n-- show tbl1 secondary_index segment 0 chunk 0'
298+
curl --request GET \
299+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/secondary_index/segment/0/chunk/0 \
300+
--header 'accept: application/json'
301+
302+
# show table tbl1 bmp_index segment 0
303+
echo -e '\n\n-- show tbl1 bmp_index segment 0'
304+
curl --request GET \
305+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index/segment/0 \
306+
--header 'accept: application/json'
307+
308+
# show table tbl1 bmp_index segment 0 chunk 0
309+
echo -e '\n\n-- show tbl1 bmp_index segment 0 chunk 0'
310+
curl --request GET \
311+
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index/segment/0/chunk/0 \
312+
--header 'accept: application/json'
313+
206314
# drop tbl1 hnsw_index
207315
echo -e '\n\n-- drop tbl1 hnsw_index'
208316
curl --request DELETE \

example/http/show_metadata.sh

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# create table 'tbl1'
2+
echo -e '-- create tbl1'
3+
curl --request POST \
4+
--url http://localhost:23820/databases/default_db/tables/tbl1 \
5+
--header 'accept: application/json' \
6+
--header 'content-type: application/json' \
7+
--data ' {
8+
"create_option": "ignore_if_exists",
9+
"fields": [
10+
{
11+
"name": "num",
12+
"type": "integer"
13+
},
14+
{
15+
"name": "body",
16+
"type": "varchar"
17+
},
18+
{
19+
"name": "vec",
20+
"type": "vector, 4, float"
21+
},
22+
{
23+
"name": "sparse_column",
24+
"type": "sparse,100,float,int"
25+
},
26+
{
27+
"name": "year",
28+
"type": "integer"
29+
},
30+
{
31+
"name": "tensor",
32+
"type": "tensor,4,float"
33+
}
34+
]
35+
} '
36+
37+
# insert 4 rows into 'tbl1'
38+
echo -e '\n\n-- insert 4 rows into tbl1'
39+
curl --request POST \
40+
--url http://localhost:23820/databases/default_db/tables/tbl1/docs \
41+
--header 'accept: application/json' \
42+
--header 'content-type: application/json' \
43+
--data '
44+
[
45+
{
46+
"num": 1,
47+
"body": "unnecessary and harmful",
48+
"vec": [1.0, 1.2, 0.8, 0.9],
49+
"sparse_column": {"10":1.1, "20":2.2, "30": 3.3},
50+
"year": 2024,
51+
"tensor": [[1.0, 0.0, 0.0, 0.0], [1.1, 0.0, 0.0, 0.0]]
52+
},
53+
{
54+
"num": 2,
55+
"body": "Office for Harmful Blooms",
56+
"vec": [4.0, 4.2, 4.3, 4.5],
57+
"sparse_column": {"40":4.4, "50":5.5, "60": 6.6},
58+
"year": 2023,
59+
"tensor": [[4.0, 0.0, 4.3, 4.5], [4.0, 4.2, 4.4, 5.0]]
60+
},
61+
{
62+
"num": 3,
63+
"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.",
64+
"vec": [4.0, 4.2, 4.3, 4.2],
65+
"sparse_column": {"70":7.7, "80":8.8, "90": 9.9},
66+
"year": 2019,
67+
"tensor": [[0.9, 0.1, 0.0, 0.0], [1.1, 0.0, 0.0, 0.0]]
68+
},
69+
{
70+
"num": 4,
71+
"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.",
72+
"vec": [4.0, 4.2, 4.3, 4.5],
73+
"sparse_column": {"20":7.7, "80":7.8, "90": 97.9},
74+
"year": 2018,
75+
"tensor": [[5.0, 4.2, 4.3, 4.5], [4.0, 4.2, 4.3, 4.4]]
76+
}
77+
] '
78+
79+
# list tables, there are 'tbl1' at least.
80+
echo -e '\n-- list tables, tbl1 should be included'
81+
curl --request GET \
82+
--url http://localhost:23820/databases/default_db/tables \
83+
--header 'accept: application/json'
84+
85+
# show table tb1
86+
echo -e '\n-- show tbl1'
87+
curl --request GET \
88+
--url http://localhost:23820/databases/default_db/tables/tbl1 \
89+
--header 'accept: application/json'
90+
91+
# show table tbl1 segments
92+
echo -e '\n-- show tbl1 segments'
93+
curl --request GET \
94+
--url http://localhost:23820/databases/default_db/tables/tbl1/segments \
95+
--header 'accept: application/json'
96+
97+
# show table tbl1 segment 0 blocks
98+
echo -e '\n-- show tbl1 segment 0 blocks'
99+
curl --request GET \
100+
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks \
101+
--header 'accept: application/json'
102+
103+
# show table tbl1 segment 0 block 0
104+
echo -e '\n-- show tbl1 segment 0 block 0'
105+
curl --request GET \
106+
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks/0 \
107+
--header 'accept: application/json'
108+
109+
# show table tbl1 segment 0 block 0 column 0
110+
echo -e '\n-- show tbl1 segment 0 block 0 column 0'
111+
curl --request GET \
112+
--url http://localhost:23820/databases/default_db/tables/tbl1/segments/0/blocks/0/0 \
113+
--header 'accept: application/json'
114+
115+
# show table tb1 columns
116+
echo -e '\n-- show tbl1 columns'
117+
curl --request GET \
118+
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
119+
--header 'accept: application/json'
120+
121+
# drop table column tbl1.year
122+
echo -e '\n-- drop table column tbl1.year'
123+
curl --request DELETE \
124+
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
125+
--header 'accept: application/json' \
126+
--header 'content-type: application/json' \
127+
--data ' {"column_names": ["year"]} '
128+
129+
# show table tbl1 columns again, tbl1.year will be gone
130+
echo -e '\n-- show tbl1 columns, tbl1.year will be gone'
131+
curl --request GET \
132+
--url http://localhost:23820/databases/default_db/tables/tbl1/columns \
133+
--header 'accept: application/json'
134+
135+
# drop tbl1
136+
echo -e '\n-- drop tbl1'
137+
curl --request DELETE \
138+
--url http://localhost:23820/databases/default_db/tables/tbl1 \
139+
--header 'accept: application/json' \
140+
--header 'content-type: application/json' \
141+
--data ' {"drop_option": "error"} '
142+
143+
# list tables, 'tbl1' is dropped.
144+
echo -e '\n-- list tables, tbl1 is dropped'
145+
curl --request GET \
146+
--url http://localhost:23820/databases/default_db/tables \
147+
--header 'accept: application/json'
148+
echo -e '\n'

0 commit comments

Comments
 (0)