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

Add more HTTP API examples #1920

Merged
merged 6 commits into from
Sep 25, 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
6 changes: 3 additions & 3 deletions docs/references/pysdk_api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1851,9 +1851,9 @@ A dictionary representing additional options for the selected reranking method:
- **match_tensor-specific options**: *Optional*
Settings when employing match_tensor for reranking.
- `"field"`: The name of the tensor column for reranking.
- `"data"`: The tensor data to compare against. This should be provided as a list of lists or a two-dimensional NumPy
- `"query_tensor"`: The tensor data to compare against. This should be provided as a list of lists or a two-dimensional NumPy
array of numerical values.
- `"data_type"`: The element data type of the query tensor. Usually `"float"`.
- `"element_type"`: The element data type of the query tensor. Usually `"float"`.

### Returns

Expand Down Expand Up @@ -1912,7 +1912,7 @@ table_object.output(["num", "body", "vec", "sparse_column", "year", "tensor", "_
.match_sparse("sparse_column", SparseVector([0, 20, 80], [1.0, 2.0, 3.0]), "ip", 3)
.match_text("body", "blooms", 10)
.filter("year < 2024")
.fusion("match_tensor", 2, {"field": "tensor", "data_type": "float", "data": [[0.0, -10.0, 0.0, 0.7], [9.2, 45.6, -55.8, 3.5]]})
.fusion("match_tensor", 2, {"field": "tensor", "element_type": "float", "query_tensor": [[0.0, -10.0, 0.0, 0.7], [9.2, 45.6, -55.8, 3.5]]})
.to_pl()
```

Expand Down
4 changes: 2 additions & 2 deletions example/ColBERT_reranker_example/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def query_fusion(self, query_str: str, output_columns: list[str], final_top_n: i
query_result = self.colbert_test_table.output(output_columns).match_text(self.inner_col_txt, query_str,
first_stage_top_n).fusion(
method='match_tensor', topn=final_top_n,
fusion_params={"field": target_col_name, "data": query_tensor.numpy(force=True),
"data_type": "float"}).to_pl()
fusion_params={"field": target_col_name, "query_tensor": query_tensor.numpy(force=True),
"element_type": "float"}).to_pl()
print(query_result)
return query_result

Expand Down
66 changes: 51 additions & 15 deletions example/http/create_list_show_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ curl --request POST \
} '

# create HNSW index on dense vector column: 'dense_column'
echo -e '\n-- create table index: hnsw_index'
echo -e '\n\n-- create table index: hnsw_index'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/hnsw_index \
--header 'accept: application/json' \
Expand All @@ -85,8 +85,30 @@ curl --request POST \
"create_option": "ignore_if_exists"
} '


echo -e '\n\n-- create table index: hnsw_index on multi_vector column'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/multi_vector_hnsw_index \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"fields":
[
"multivector_column"
],
"index":
{
"type": "Hnsw",
"M": "16",
"ef_construction": "50",
"metric": "l2"
},
"create_option": "ignore_if_exists"
} '

# create Full-text index on varchar column: 'fulltext_column'
echo -e '\n-- create table index: fulltext_index'
echo -e '\n\n-- create table index: fulltext_index'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/fulltext_index \
--header 'accept: application/json' \
Expand All @@ -106,7 +128,7 @@ curl --request POST \
} '

# create secondary index on varchar column: 'name'
echo -e '\n-- create table index: secondary_index'
echo -e '\n\n-- create table index: secondary_index'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/secondary_index \
--header 'accept: application/json' \
Expand All @@ -125,7 +147,7 @@ curl --request POST \
} '

# create sparse vector index on sparse vector column: 'sparse_column'
echo -e '\n-- create table index: bmp_index'
echo -e '\n\n-- create table index: bmp_index'
curl --request POST \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes/bmp_index \
--header 'accept: application/json' \
Expand All @@ -146,75 +168,89 @@ curl --request POST \


# list table indexes
echo -e '\n-- list table indexes: hnsw_index, sparse_index, fulltext_index, bmp_index should be included'
echo -e '\n\n-- list table indexes: hnsw_index, sparse_index, fulltext_index, bmp_index should be included'
curl --request GET \
--url http://localhost:23820/databases/default_db/tables/tbl1/indexes \
--header 'accept: application/json'

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

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

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

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

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

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

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

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

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

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

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

# drop tbl1
echo -e '\n-- drop tbl1'
echo -e '\n\n-- drop tbl1'
curl --request DELETE \
--url http://localhost:23820/databases/default_db/tables/tbl1 \
--header 'accept: application/json' \
Expand Down
Loading
Loading