nucliadb 6.3.0.post3415__py3-none-any.whl → 6.3.0.post3417__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.
- migrations/pg/0004_catalog_facets.py +51 -0
- nucliadb/search/search/pgcatalog.py +2 -2
- {nucliadb-6.3.0.post3415.dist-info → nucliadb-6.3.0.post3417.dist-info}/METADATA +6 -6
- {nucliadb-6.3.0.post3415.dist-info → nucliadb-6.3.0.post3417.dist-info}/RECORD +7 -6
- {nucliadb-6.3.0.post3415.dist-info → nucliadb-6.3.0.post3417.dist-info}/WHEEL +0 -0
- {nucliadb-6.3.0.post3415.dist-info → nucliadb-6.3.0.post3417.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.0.post3415.dist-info → nucliadb-6.3.0.post3417.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
+
#
|
3
|
+
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
+
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
+
#
|
6
|
+
# AGPL:
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as
|
9
|
+
# published by the Free Software Foundation, either version 3 of the
|
10
|
+
# License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
from nucliadb.common.maindb.pg import PGTransaction
|
22
|
+
|
23
|
+
|
24
|
+
async def migrate(txn: PGTransaction) -> None:
|
25
|
+
async with txn.connection.cursor() as cur:
|
26
|
+
await cur.execute("""
|
27
|
+
CREATE OR REPLACE FUNCTION extract_facets(facets TEXT[])
|
28
|
+
RETURNS TEXT[] AS $$
|
29
|
+
SELECT array_agg(prefix) FROM (
|
30
|
+
SELECT DISTINCT p.prefix
|
31
|
+
FROM unnest(facets) AS facet,
|
32
|
+
LATERAL (
|
33
|
+
SELECT string_agg(part, '/') OVER(ROWS UNBOUNDED PRECEDING) AS prefix
|
34
|
+
FROM regexp_split_to_table(facet, '/') AS part
|
35
|
+
) AS p
|
36
|
+
) AS s
|
37
|
+
WHERE prefix != '';
|
38
|
+
$$ LANGUAGE SQL IMMUTABLE;
|
39
|
+
""")
|
40
|
+
|
41
|
+
# Concurrent index must be created outside of a transaction but psycopg automatically
|
42
|
+
# creates transactions. We temporarily disable this for this single statement.
|
43
|
+
await txn.connection.commit()
|
44
|
+
try:
|
45
|
+
await txn.connection.set_autocommit(True)
|
46
|
+
await txn.connection.execute(
|
47
|
+
"CREATE INDEX CONCURRENTLY ON catalog USING gin (kbid, extract_facets(labels));"
|
48
|
+
)
|
49
|
+
await txn.connection.execute("ANALYZE catalog")
|
50
|
+
finally:
|
51
|
+
await txn.connection.set_autocommit(False)
|
@@ -61,7 +61,7 @@ def _convert_filter(filter, filter_params):
|
|
61
61
|
if op == "literal":
|
62
62
|
param_name = f"param{len(filter_params)}"
|
63
63
|
filter_params[param_name] = [operands]
|
64
|
-
return f"labels @> %({param_name})s"
|
64
|
+
return f"extract_facets(labels) @> %({param_name})s"
|
65
65
|
elif op in ("and", "or"):
|
66
66
|
array_op = "@>" if op == "and" else "&&"
|
67
67
|
sql = []
|
@@ -69,7 +69,7 @@ def _convert_filter(filter, filter_params):
|
|
69
69
|
if literals:
|
70
70
|
param_name = f"param{len(filter_params)}"
|
71
71
|
filter_params[param_name] = literals
|
72
|
-
sql.append(f"labels {array_op} %({param_name})s")
|
72
|
+
sql.append(f"extract_facets(labels) {array_op} %({param_name})s")
|
73
73
|
for nonlit in nonliterals:
|
74
74
|
sql.append(_convert_filter(nonlit, filter_params))
|
75
75
|
return "(" + f" {op.upper()} ".join(sql) + ")"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.0.
|
3
|
+
Version: 6.3.0.post3417
|
4
4
|
Summary: NucliaDB
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
6
6
|
License: AGPL
|
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
21
21
|
Requires-Python: <4,>=3.9
|
22
22
|
Description-Content-Type: text/markdown
|
23
|
-
Requires-Dist: nucliadb-telemetry[all]>=6.3.0.
|
24
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.0.
|
25
|
-
Requires-Dist: nucliadb-protos>=6.3.0.
|
26
|
-
Requires-Dist: nucliadb-models>=6.3.0.
|
27
|
-
Requires-Dist: nidx-protos>=6.3.0.
|
23
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.3.0.post3417
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.0.post3417
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.0.post3417
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.0.post3417
|
27
|
+
Requires-Dist: nidx-protos>=6.3.0.post3417
|
28
28
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
29
29
|
Requires-Dist: nuclia-models>=0.24.2
|
30
30
|
Requires-Dist: uvicorn
|
@@ -31,6 +31,7 @@ migrations/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
|
31
31
|
migrations/pg/0001_bootstrap.py,sha256=Fsqkeof50m7fKiJN05kmNEMwiKDlOrAgcAS5sLLkutA,1256
|
32
32
|
migrations/pg/0002_catalog.py,sha256=Rsleecu351Ty19kYZgOpqX5G3MEAY8nMxCJrAeuS2Mw,1690
|
33
33
|
migrations/pg/0003_catalog_kbid_index.py,sha256=uKq_vtnuf73GVf0mtl2rhzdk_czAoEU1UdiVKVZpA0M,1044
|
34
|
+
migrations/pg/0004_catalog_facets.py,sha256=FJFASHjfEHG3sNve9BP2HnnLO4xr7dnR6Qpctnmt4LE,2180
|
34
35
|
migrations/pg/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
35
36
|
nucliadb/__init__.py,sha256=_abCmDJ_0ku483Os4UAjPX7Nywm39cQgAV_DiyjsKeQ,891
|
36
37
|
nucliadb/health.py,sha256=UIxxA4oms4HIsCRZM_SZsdkIZIlgzmOxw-qSHLlWuak,3465
|
@@ -222,7 +223,7 @@ nucliadb/search/search/ingestion_agents.py,sha256=NeJr4EEX-bvFFMGvXOOwLv8uU7NuQ-
|
|
222
223
|
nucliadb/search/search/merge.py,sha256=i_PTBFRqC5iTTziOMEltxLIlmokIou5hjjgR4BnoLBE,22635
|
223
224
|
nucliadb/search/search/metrics.py,sha256=81X-tahGW4n2CLvUzCPdNxNClmZqUWZjcVOGCUHoiUM,2872
|
224
225
|
nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
|
225
|
-
nucliadb/search/search/pgcatalog.py,sha256=
|
226
|
+
nucliadb/search/search/pgcatalog.py,sha256=hNZJtbke0kFz9ygz70gMMJz9NxhRPznefCad83yQPd4,8887
|
226
227
|
nucliadb/search/search/predict_proxy.py,sha256=IFI3v_ODz2_UU1XZnyaD391fE7-2C0npSmj_HmDvzS4,3123
|
227
228
|
nucliadb/search/search/query.py,sha256=j7NdAXQXSytWvf_tyqpG-Fz4AhVGI-Y5i7NPm3s7-PI,29980
|
228
229
|
nucliadb/search/search/rank_fusion.py,sha256=tRGo_KlsFsVx1CQEy1iqQ6f0T1Dq1kf0axDXHuuzvvM,6946
|
@@ -338,8 +339,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
338
339
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
339
340
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
340
341
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
341
|
-
nucliadb-6.3.0.
|
342
|
-
nucliadb-6.3.0.
|
343
|
-
nucliadb-6.3.0.
|
344
|
-
nucliadb-6.3.0.
|
345
|
-
nucliadb-6.3.0.
|
342
|
+
nucliadb-6.3.0.post3417.dist-info/METADATA,sha256=Nya_zwsp_AAX_HD3Qf6w7Hwd5UpeppIBUeCi9qqCnro,4291
|
343
|
+
nucliadb-6.3.0.post3417.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
|
344
|
+
nucliadb-6.3.0.post3417.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
345
|
+
nucliadb-6.3.0.post3417.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
346
|
+
nucliadb-6.3.0.post3417.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|