Skip to content

Commit b33309f

Browse files
committed
fix pgvecto_rs: fix index and query parameters
1 parent 8dbf70b commit b33309f

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

engine/clients/pgvector/search.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ def search_one(cls, vector: List[float], meta_conditions, top: Optional[int], sc
3333
cur.execute("BEGIN;")
3434
# set index create parameter
3535
for key in cls.search_params["params"].keys():
36-
if cls.engine_type == "c":
37-
cur.execute(f"SET LOCAL {key} = {cls.search_params['params'][key]};")
38-
else:
39-
# pgvector_rs only support hnsw
40-
cur.execute(f"SET LOCAL vectors.k = {cls.search_params['params']['hnsw.ef_search']};")
41-
break
36+
cur.execute(f"SET LOCAL {key} = {cls.search_params['params'][key]};")
37+
4238

4339
meta_conditions = cls.parser.parse(meta_conditions)
4440
if meta_conditions:

engine/clients/pgvector/upload.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ def post_upload(cls, distance):
7474
if cls.engine_type == "rust":
7575
create_index_command = f"""
7676
CREATE INDEX ON {PGVECTOR_INDEX} USING vectors (vector {cls.distance}) WITH (options=$$
77-
capacity = {int(cls.vector_count*1.2)}
78-
[vectors]
79-
memmap = "ram"
80-
[algorithm.hnsw]
81-
memmap = "ram"
77+
[indexing.hnsw]
8278
{index_options_rust}
8379
$$);
8480
"""

experiments/needs_editing/pgvector_rust_HNSW_single_node_laion-768-5m-ip.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@
2424
"parallel": 4,
2525
"top": 10,
2626
"params": {
27-
"hnsw.ef_search": 100
27+
"vectors.hnsw_ef_search": 100
2828
}
2929
},
3030
{
3131
"parallel": 4,
3232
"top": 100,
3333
"params": {
34-
"hnsw.ef_search": 100
34+
"vectors.hnsw_ef_search": 100
3535
}
3636
},
3737
{
3838
"parallel": 8,
3939
"top": 10,
4040
"params": {
41-
"hnsw.ef_search": 100
41+
"vectors.hnsw_ef_search": 100
4242
}
4343
},
4444
{
4545
"parallel": 8,
4646
"top": 100,
4747
"params": {
48-
"hnsw.ef_search": 100
48+
"vectors.hnsw_ef_search": 100
4949
}
5050
}
5151
],

experiments/needs_editing/pgvector_rust_HNSW_single_node_laion-768-5m-probability-ip.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"parallel": 4,
2525
"top": 10,
2626
"params": {
27-
"hnsw.ef_search": 100
27+
"vectors.hnsw_ef_search": 100
2828
},
2929
"query_meta": {
3030
"probability": 0.01
@@ -34,7 +34,7 @@
3434
"parallel": 4,
3535
"top": 10,
3636
"params": {
37-
"hnsw.ef_search": 100
37+
"vectors.hnsw_ef_search": 100
3838
},
3939
"query_meta": {
4040
"probability": 0.1
@@ -44,7 +44,7 @@
4444
"parallel": 4,
4545
"top": 100,
4646
"params": {
47-
"hnsw.ef_search": 100
47+
"vectors.hnsw_ef_search": 100
4848
},
4949
"query_meta": {
5050
"probability": 0.01
@@ -54,7 +54,7 @@
5454
"parallel": 4,
5555
"top": 100,
5656
"params": {
57-
"hnsw.ef_search": 100
57+
"vectors.hnsw_ef_search": 100
5858
},
5959
"query_meta": {
6060
"probability": 0.1
@@ -64,7 +64,7 @@
6464
"parallel": 8,
6565
"top": 10,
6666
"params": {
67-
"hnsw.ef_search": 100
67+
"vectors.hnsw_ef_search": 100
6868
},
6969
"query_meta": {
7070
"probability": 0.01
@@ -74,7 +74,7 @@
7474
"parallel": 8,
7575
"top": 10,
7676
"params": {
77-
"hnsw.ef_search": 100
77+
"vectors.hnsw_ef_search": 100
7878
},
7979
"query_meta": {
8080
"probability": 0.1
@@ -84,7 +84,7 @@
8484
"parallel": 8,
8585
"top": 100,
8686
"params": {
87-
"hnsw.ef_search": 100
87+
"vectors.hnsw_ef_search": 100
8888
},
8989
"query_meta": {
9090
"probability": 0.01
@@ -94,7 +94,7 @@
9494
"parallel": 8,
9595
"top": 100,
9696
"params": {
97-
"hnsw.ef_search": 100
97+
"vectors.hnsw_ef_search": 100
9898
},
9999
"query_meta": {
100100
"probability": 0.1

0 commit comments

Comments
 (0)