pyobvector 0.2.17__tar.gz → 0.2.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyobvector-0.2.17 → pyobvector-0.2.18}/PKG-INFO +6 -2
- {pyobvector-0.2.17 → pyobvector-0.2.18}/README.md +5 -1
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/exceptions.py +1 -1
- pyobvector-0.2.18/pyobvector/client/hybrid_search.py +81 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/ob_vec_client.py +1 -1
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyproject.toml +1 -1
- {pyobvector-0.2.17 → pyobvector-0.2.18}/LICENSE +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/__init__.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/__init__.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/collection_schema.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/enum.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/fts_index_param.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/index_param.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/milvus_like_client.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/ob_client.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/ob_vec_json_table_client.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/partitions.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/client/schema_type.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/json_table/__init__.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/json_table/json_value_returning_func.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/json_table/oceanbase_dialect.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/json_table/virtual_data_type.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/__init__.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/array.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/dialect.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/full_text_index.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/geo_srid_point.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/gis_func.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/match_against_func.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/ob_table.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/reflection.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/replace_stmt.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/sparse_vector.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/vec_dist_func.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/vector.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/schema/vector_index.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/util/__init__.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/util/ob_version.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/util/sparse_vector.py +0 -0
- {pyobvector-0.2.17 → pyobvector-0.2.18}/pyobvector/util/vector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobvector
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.18
|
|
4
4
|
Summary: A python SDK for OceanBase Vector Store, based on SQLAlchemy, compatible with Milvus API.
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: shanhaikang.shk
|
|
@@ -38,7 +38,7 @@ poetry install
|
|
|
38
38
|
- install with pip:
|
|
39
39
|
|
|
40
40
|
```shell
|
|
41
|
-
pip install pyobvector==0.2.
|
|
41
|
+
pip install pyobvector==0.2.18
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## Build Doc
|
|
@@ -50,6 +50,10 @@ mkdir build
|
|
|
50
50
|
make html
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## Release Notes
|
|
54
|
+
|
|
55
|
+
For detailed release notes and changelog, see [RELEASE_NOTES.md](RELEASE_NOTES.md).
|
|
56
|
+
|
|
53
57
|
## Usage
|
|
54
58
|
|
|
55
59
|
`pyobvector` supports two modes:
|
|
@@ -15,7 +15,7 @@ poetry install
|
|
|
15
15
|
- install with pip:
|
|
16
16
|
|
|
17
17
|
```shell
|
|
18
|
-
pip install pyobvector==0.2.
|
|
18
|
+
pip install pyobvector==0.2.18
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Build Doc
|
|
@@ -27,6 +27,10 @@ mkdir build
|
|
|
27
27
|
make html
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Release Notes
|
|
31
|
+
|
|
32
|
+
For detailed release notes and changelog, see [RELEASE_NOTES.md](RELEASE_NOTES.md).
|
|
33
|
+
|
|
30
34
|
## Usage
|
|
31
35
|
|
|
32
36
|
`pyobvector` supports two modes:
|
|
@@ -111,5 +111,5 @@ class ExceptionsMessage:
|
|
|
111
111
|
MetricTypeValueInvalid = "MetricType should be 'l2'/'ip'/'neg_ip'/'cosine' in ann search."
|
|
112
112
|
UsingInIDsWhenMultiPrimaryKey = "Using 'ids' when table has multi primary key."
|
|
113
113
|
ClusterVersionIsLow = (
|
|
114
|
-
"OceanBase
|
|
114
|
+
"OceanBase %s feature is not supported because cluster version is below %s."
|
|
115
115
|
)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""OceanBase Hybrid Search Client."""
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Dict, Any
|
|
5
|
+
|
|
6
|
+
from sqlalchemy import text
|
|
7
|
+
|
|
8
|
+
from .exceptions import ClusterVersionException, ErrorCode, ExceptionsMessage
|
|
9
|
+
from .ob_vec_client import ObVecClient as Client
|
|
10
|
+
from ..util import ObVersion
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
logger.setLevel(logging.DEBUG)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HybridSearch(Client):
|
|
17
|
+
"""The OceanBase Hybrid Search Client"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
uri: str = "127.0.0.1:2881",
|
|
22
|
+
user: str = "root@test",
|
|
23
|
+
password: str = "",
|
|
24
|
+
db_name: str = "test",
|
|
25
|
+
**kwargs,
|
|
26
|
+
):
|
|
27
|
+
super().__init__(uri, user, password, db_name, **kwargs)
|
|
28
|
+
|
|
29
|
+
if self.ob_version < ObVersion.from_db_version_nums(4, 4, 1, 0):
|
|
30
|
+
raise ClusterVersionException(
|
|
31
|
+
code=ErrorCode.NOT_SUPPORTED,
|
|
32
|
+
message=ExceptionsMessage.ClusterVersionIsLow % ("Hybrid Search", "4.4.1.0"),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def search(
|
|
36
|
+
self,
|
|
37
|
+
index: str,
|
|
38
|
+
body: Dict[str, Any],
|
|
39
|
+
**kwargs,
|
|
40
|
+
):
|
|
41
|
+
"""Execute hybrid search with parameter compatible with Elasticsearch.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
index: The name of the table to search
|
|
45
|
+
body: The search query body
|
|
46
|
+
**kwargs: Additional search parameters
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
Search results
|
|
50
|
+
"""
|
|
51
|
+
body_str = json.dumps(body)
|
|
52
|
+
|
|
53
|
+
sql = text("SELECT DBMS_HYBRID_SEARCH.SEARCH(:index, :body_str)")
|
|
54
|
+
|
|
55
|
+
with self.engine.connect() as conn:
|
|
56
|
+
with conn.begin():
|
|
57
|
+
res = conn.execute(sql, {"index": index, "body_str": body_str}).fetchone()
|
|
58
|
+
return json.loads(res[0])
|
|
59
|
+
|
|
60
|
+
def get_sql(
|
|
61
|
+
self,
|
|
62
|
+
index: str,
|
|
63
|
+
body: Dict[str, Any],
|
|
64
|
+
) -> str:
|
|
65
|
+
"""Get the SQL actually to be executed in hybrid search.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
index: The name of the table to search
|
|
69
|
+
body: The hybrid search query body
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
The SQL actually to be executed
|
|
73
|
+
"""
|
|
74
|
+
body_str = json.dumps(body)
|
|
75
|
+
|
|
76
|
+
sql = text("SELECT DBMS_HYBRID_SEARCH.GET_SQL(:index, :body_str)")
|
|
77
|
+
|
|
78
|
+
with self.engine.connect() as conn:
|
|
79
|
+
with conn.begin():
|
|
80
|
+
res = conn.execute(sql, {"index": index, "body_str": body_str}).fetchone()
|
|
81
|
+
return res[0]
|
|
@@ -44,7 +44,7 @@ class ObVecClient(ObClient):
|
|
|
44
44
|
if self.ob_version < ObVersion.from_db_version_nums(4, 3, 3, 0):
|
|
45
45
|
raise ClusterVersionException(
|
|
46
46
|
code=ErrorCode.NOT_SUPPORTED,
|
|
47
|
-
message=ExceptionsMessage.ClusterVersionIsLow,
|
|
47
|
+
message=ExceptionsMessage.ClusterVersionIsLow % ("Vector Store", "4.3.3.0"),
|
|
48
48
|
)
|
|
49
49
|
|
|
50
50
|
def _get_sparse_vector_index_params(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "pyobvector"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.18"
|
|
4
4
|
description = "A python SDK for OceanBase Vector Store, based on SQLAlchemy, compatible with Milvus API."
|
|
5
5
|
authors = ["shanhaikang.shk <shanhaikang.shk@oceanbase.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|