oarepo-runtime 1.5.40__py3-none-any.whl → 1.5.42__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.
@@ -146,6 +146,12 @@ class ICUSearchField(ICUField):
146
146
  "tokenizer": "standard",
147
147
  "filter": ["stemming_filter_en"],
148
148
  },
149
+ "ascii_folding_analyzer": {
150
+ "tokenizer": "standard",
151
+ "filter": [
152
+ "ascii_folding_filter"
153
+ ]
154
+ },
149
155
  }
150
156
 
151
157
  default_stemming_filters = {
@@ -159,6 +165,10 @@ class ICUSearchField(ICUField):
159
165
  "name": "english",
160
166
  "language": "english",
161
167
  },
168
+ "ascii_folding_filter": {
169
+ "type": "asciifolding",
170
+ "preserve_original": True
171
+ }
162
172
  }
163
173
 
164
174
  def __init__(self, source_field, key=None):
@@ -170,11 +180,24 @@ class ICUSearchField(ICUField):
170
180
  self.attr_name: {
171
181
  "type": "object",
172
182
  "properties": {
183
+ # normal stemming
173
184
  lang: setting.get(
174
185
  "search",
175
186
  {
176
187
  "type": "text",
177
- "analyzer": f"stemming_analyzer_{lang}",
188
+ "boost": 1,
189
+ "fields": {
190
+ "stemmed": {
191
+ "type": "text",
192
+ "analyzer": f"stemming_analyzer_{lang}",
193
+ "boost": 0.5,
194
+ },
195
+ "ascii_folded": {
196
+ "type": "text",
197
+ "analyzer": "ascii_folding_analyzer",
198
+ "boost": 0.3,
199
+ },
200
+ }
178
201
  },
179
202
  )
180
203
  for lang, setting in self.languages.items()
@@ -82,6 +82,12 @@ class OwnersField(MappingSystemFieldMixin, SystemField):
82
82
  return {
83
83
  self.attr_name: {
84
84
  "type": "object",
85
+ "properties": {
86
+ "user": {
87
+ "type": "keyword",
88
+ "ignore_above": 256
89
+ }
90
+ }
85
91
  },
86
92
  }
87
93
 
@@ -19,7 +19,7 @@ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
19
19
  class Mapping(InvenioMapping):
20
20
  @classmethod
21
21
  def properties_for_fields(
22
- cls, given_fields_names, available_fields, field_name="custom_fields"
22
+ cls, given_fields_names, available_fields, field_name="custom_fields"
23
23
  ):
24
24
  """Prepare search mapping properties for each field."""
25
25
 
@@ -34,7 +34,7 @@ class Mapping(InvenioMapping):
34
34
 
35
35
  @classmethod
36
36
  def settings_for_fields(
37
- cls, given_fields_names, available_fields, field_name="custom_fields"
37
+ cls, given_fields_names, available_fields, field_name="custom_fields"
38
38
  ):
39
39
  """Prepare mapping settings for each field."""
40
40
 
@@ -72,10 +72,11 @@ def prepare_cf_indices():
72
72
  if record_class:
73
73
  prepare_cf_index(record_class, config)
74
74
  parent_class = getattr(record_class, "parent_record_cls", None)
75
- prepare_cf_index(parent_class, config)
75
+ prepare_parent_mapping(parent_class, config)
76
+ prepare_cf_index(parent_class, config, path=["parent", "properties"])
76
77
 
77
78
 
78
- def prepare_cf_index(record_class, config):
79
+ def prepare_cf_index(record_class, config, path=[]):
79
80
  if not record_class:
80
81
  return
81
82
 
@@ -85,6 +86,11 @@ def prepare_cf_index(record_class, config):
85
86
  settings = fld.mapping_settings
86
87
  dynamic_templates = fld.dynamic_templates
87
88
 
89
+ for pth in reversed(path):
90
+ mapping = {
91
+ pth: mapping
92
+ }
93
+
88
94
  # upload mapping
89
95
  try:
90
96
  record_index = dsl.Index(
@@ -109,6 +115,79 @@ def prepare_cf_index(record_class, config):
109
115
  click.secho(e.info["error"]["reason"], fg="red")
110
116
 
111
117
 
118
+ def prepare_parent_mapping(parent_class, config):
119
+ if not parent_class:
120
+ return
121
+ parent_mapping = {
122
+ "parent": {
123
+ "type": "object",
124
+ "properties": {
125
+ "created": {
126
+ "type": "date",
127
+ "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
128
+ },
129
+ "id": {
130
+ "type": "keyword",
131
+ "ignore_above": 1024
132
+ },
133
+ "pid": {
134
+ "properties": {
135
+ "obj_type": {
136
+ "type": "keyword",
137
+ "ignore_above": 1024
138
+ },
139
+ "pid_type": {
140
+ "type": "keyword",
141
+ "ignore_above": 1024
142
+ },
143
+ "pk": {
144
+ "type": "long"
145
+ },
146
+ "status": {
147
+ "type": "keyword",
148
+ "ignore_above": 1024
149
+ }
150
+ }
151
+ },
152
+ "updated": {
153
+ "type": "date",
154
+ "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
155
+ },
156
+ "uuid": {
157
+ "type": "keyword",
158
+ "ignore_above": 1024
159
+ },
160
+ "version_id": {
161
+ "type": "long"
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ # upload mapping
168
+ try:
169
+ record_index = dsl.Index(
170
+ build_alias_name(
171
+ config.record_cls.index._name,
172
+ ),
173
+ using=current_search_client,
174
+ )
175
+ update_index(record_index, {}, parent_mapping)
176
+
177
+ if hasattr(config, "draft_cls"):
178
+ draft_index = dsl.Index(
179
+ build_alias_name(
180
+ config.draft_cls.index._name,
181
+ ),
182
+ using=current_search_client,
183
+ )
184
+ update_index(draft_index, {}, parent_mapping)
185
+
186
+ except search.RequestError as e:
187
+ click.secho("An error occurred while creating parent mapping.", fg="red")
188
+ click.secho(e.info["error"]["reason"], fg="red")
189
+
190
+
112
191
  def update_index(record_index, settings, mapping, dynamic_templates=None):
113
192
  if settings:
114
193
  record_index.close()
@@ -125,6 +204,6 @@ def update_index(record_index, settings, mapping, dynamic_templates=None):
125
204
 
126
205
  def get_mapping_fields(record_class) -> Iterable[MappingSystemFieldMixin]:
127
206
  for cfg_name, cfg_value in inspect.getmembers(
128
- record_class, lambda x: isinstance(x, MappingSystemFieldMixin)
207
+ record_class, lambda x: isinstance(x, MappingSystemFieldMixin)
129
208
  ):
130
209
  yield cfg_value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.40
3
+ Version: 1.5.42
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -58,9 +58,9 @@ oarepo_runtime/records/relations/pid_relation.py,sha256=zJjSf_ocFBViYsOuMMZLbQZp
58
58
  oarepo_runtime/records/systemfields/__init__.py,sha256=SPaMWM6t-azz6gZLUKvvXbOyE2_-LW6i_szQk8nhbAc,455
59
59
  oarepo_runtime/records/systemfields/featured_file.py,sha256=MbSaYR130_o5S9gEOblnChq-PVK4xGPGpSCrzwG3cwc,1720
60
60
  oarepo_runtime/records/systemfields/has_draftcheck.py,sha256=4JkMEefPLpqtPtlTgK3UT0KzTRgyw5_Qtkss2qcz5xk,1643
61
- oarepo_runtime/records/systemfields/icu.py,sha256=tAwplzy9y7C9Dm7HqcGZsDu2AKqVGXhCbKLsFlgVWg8,5921
61
+ oarepo_runtime/records/systemfields/icu.py,sha256=CINwl5amyW9fuSd89Nz5bm9iSeyNX8xdjZ6sUakG71Q,6799
62
62
  oarepo_runtime/records/systemfields/mapping.py,sha256=tXOK_jkdY1pOUO7_VfChfDNB8UTi21GUXaidpugTnO8,1017
63
- oarepo_runtime/records/systemfields/owner.py,sha256=uv2eTss0GyMHLXaxDUFwwM_lwbbRBH_0ALxVUOKFCoI,3755
63
+ oarepo_runtime/records/systemfields/owner.py,sha256=U7CD71Ve9midaH72pV4A4_I7AdywqZW0BSRHAK10_qA,3944
64
64
  oarepo_runtime/records/systemfields/record_status.py,sha256=U3kem4-JkNsT17e0iAl3HIAZ2MvO5lY_0U757aZvTKE,935
65
65
  oarepo_runtime/records/systemfields/selectors.py,sha256=VlbV3FKP2h3PLU7H4-YsI4qrb0UO_SrhJ2dcsTBGoqI,900
66
66
  oarepo_runtime/records/systemfields/synthetic.py,sha256=GC7g6BZSQqVV7bFk3x6Y1E4dFgvX7VwHuIFXEDpmuSs,4238
@@ -76,7 +76,7 @@ oarepo_runtime/services/config/__init__.py,sha256=SCqww5sV8qh3gmev6TE8EyJbD58juI
76
76
  oarepo_runtime/services/config/permissions_presets.py,sha256=zApeA-2DYAlD--SzVz3vq_OFjq48Ko0pe08e4o2vxr4,6114
77
77
  oarepo_runtime/services/config/service.py,sha256=2aq5jobPH22T1QqlJDommvAxJwo9aQGiqK5q-k-l9CA,4668
78
78
  oarepo_runtime/services/custom_fields/__init__.py,sha256=xJ7XEyMJHPfIgX5JKpgpwh7SYc9Zee2dC5oC8cm99Qc,2282
79
- oarepo_runtime/services/custom_fields/mappings.py,sha256=CYJJAGo4k6Bv6D5FLy4Js9EjhWWNThJBkosAMdZIXzI,4600
79
+ oarepo_runtime/services/custom_fields/mappings.py,sha256=d2uWqk-x4nfoxMx7Uw_PGWKba_Wlf_ukpRB5ruU-RPU,7397
80
80
  oarepo_runtime/services/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
81
  oarepo_runtime/services/expansions/expandable_fields.py,sha256=7DWKFL6ml8J7zGI6wm9LO7Xd6R0LSylsuq4lyRumNHQ,745
82
82
  oarepo_runtime/services/expansions/service.py,sha256=HaEy76XOhDf__sQ91hi-8iH1hthM9q07pRhOmyZyVrs,144
@@ -116,9 +116,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
116
116
  oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
117
117
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
118
118
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
119
- oarepo_runtime-1.5.40.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
120
- oarepo_runtime-1.5.40.dist-info/METADATA,sha256=ACzPUTjB7ln5HYSSmBh4szWrV-E3bPfPpUinQIcweiY,4680
121
- oarepo_runtime-1.5.40.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
122
- oarepo_runtime-1.5.40.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
123
- oarepo_runtime-1.5.40.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
124
- oarepo_runtime-1.5.40.dist-info/RECORD,,
119
+ oarepo_runtime-1.5.42.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
120
+ oarepo_runtime-1.5.42.dist-info/METADATA,sha256=CkuQUP34z5vt1hqEP4g12GJw2Axu7ThaKs65XPXMtMw,4680
121
+ oarepo_runtime-1.5.42.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
122
+ oarepo_runtime-1.5.42.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
123
+ oarepo_runtime-1.5.42.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
124
+ oarepo_runtime-1.5.42.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5