pyobvector 0.2.17__py3-none-any.whl → 0.2.18__py3-none-any.whl

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.
@@ -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 Vector Store is not supported because cluster version is below 4.3.3.0."
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
  Metadata-Version: 2.4
2
2
  Name: pyobvector
3
- Version: 0.2.17
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.17
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:
@@ -2,12 +2,13 @@ pyobvector/__init__.py,sha256=5RtWI_ol3qxj_m7UXTQzByTmGZdIiQ0yyCyHZUhRDas,3888
2
2
  pyobvector/client/__init__.py,sha256=fDK2FVdSm3-XCwTqsam7zisic5UMhANUq97r29i27nc,2819
3
3
  pyobvector/client/collection_schema.py,sha256=a7JQk83ZxMsvMDGt5CC_4lz2-skONqKgk-OGUz297hM,5538
4
4
  pyobvector/client/enum.py,sha256=3lPjSltITSE694-qOAP4yoX6fzCjKD4WAewmIxFs49o,139
5
- pyobvector/client/exceptions.py,sha256=09WNeWA0g7DWATVNGSX6ZJR_NoaGIZ4NB9M-BtQNYO8,3784
5
+ pyobvector/client/exceptions.py,sha256=CjoquSCc0H705MtvhpQW_F7_KaviYrKAHkndpF8sJx4,3777
6
6
  pyobvector/client/fts_index_param.py,sha256=UvU82p9_x444WAQMqhIUPHbqVHV5B3cFazje1Gw-slo,1105
7
+ pyobvector/client/hybrid_search.py,sha256=RRjWGpSu625-ND-eZq0_JPL9OAP548XkOI9I9U-mTG4,2323
7
8
  pyobvector/client/index_param.py,sha256=Dg-FEFQPBRxb7qXChqoLgBSljpdJzF-C7ESUbG9x1mA,6926
8
9
  pyobvector/client/milvus_like_client.py,sha256=jHxB-ZmIGZiIDxEpurSlAKffiCF_KFNZP-14_vq1RQM,27887
9
10
  pyobvector/client/ob_client.py,sha256=csSRVWqbhnsaN2gj7FSwL7QExh4vbTx6EyqPznKRSz4,16172
10
- pyobvector/client/ob_vec_client.py,sha256=6w6jmHzqDZ938_bOzhz3NQDNe6BxEIwN8PwXQt2NPjU,19886
11
+ pyobvector/client/ob_vec_client.py,sha256=P6IMtsYxS_S78VsQtltK3UenW91iYfRKa0s1hIc8CI0,19916
11
12
  pyobvector/client/ob_vec_json_table_client.py,sha256=rq80AfqAKhosLcrBFROAoINVSkr-48xlRH91Jt4pEwA,39246
12
13
  pyobvector/client/partitions.py,sha256=Bxwr5yVNlXwZc7SXBC03NeqL9giy4Fe6S2qZdHD8xGw,15621
13
14
  pyobvector/client/schema_type.py,sha256=gH2YiBsgkryo-R0GB_NYuRXMvzvrSjOamZTy6pwn2n0,1673
@@ -33,7 +34,7 @@ pyobvector/util/__init__.py,sha256=-opvZ4Ya0ByTAhls06547-zW3vkdYRkUH6W5OCKUHD4,3
33
34
  pyobvector/util/ob_version.py,sha256=cWkQWoJkIxG6OEF9-gBwJK8LUorltHuKSVAb_NFkpdE,1542
34
35
  pyobvector/util/sparse_vector.py,sha256=1IG0CRYfC2z39nGwuG43TImQkWiuPAXOlOnYqJ1hA-o,1275
35
36
  pyobvector/util/vector.py,sha256=58glSQqjOSTrGyNhUEIrs9r4F9oaYO_SdPNhMfbSnWs,2392
36
- pyobvector-0.2.17.dist-info/METADATA,sha256=84qltXOoooYKNqPE-gNyunQioq2AIIvIJB4qRxLGKJY,8965
37
- pyobvector-0.2.17.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
38
- pyobvector-0.2.17.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
39
- pyobvector-0.2.17.dist-info/RECORD,,
37
+ pyobvector-0.2.18.dist-info/METADATA,sha256=vqKxp4TJISXO73RxmXxqAPbzZERDoO-MwhPGruxYpXc,9068
38
+ pyobvector-0.2.18.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
39
+ pyobvector-0.2.18.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
40
+ pyobvector-0.2.18.dist-info/RECORD,,