oarepo-runtime 1.5.39__py3-none-any.whl → 1.5.41__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -78,6 +78,19 @@ class GroupedFacetsParam(FacetsParam):
78
78
 
79
79
  return search
80
80
 
81
+ def filter(self, search):
82
+ """Apply a post filter on the search."""
83
+ if not self._filters:
84
+ return search
85
+
86
+ filters = list(self._filters.values())
87
+
88
+ _filter = filters[0]
89
+ for f in filters[1:]:
90
+ _filter &= f
91
+
92
+ return search.filter(_filter)
93
+
81
94
  def apply(self, identity, search, params):
82
95
  """Evaluate the facets on the search."""
83
96
  facets_values = params.pop("facets", {})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.39
3
+ Version: 1.5.41
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -60,7 +60,7 @@ oarepo_runtime/records/systemfields/featured_file.py,sha256=MbSaYR130_o5S9gEObln
60
60
  oarepo_runtime/records/systemfields/has_draftcheck.py,sha256=4JkMEefPLpqtPtlTgK3UT0KzTRgyw5_Qtkss2qcz5xk,1643
61
61
  oarepo_runtime/records/systemfields/icu.py,sha256=tAwplzy9y7C9Dm7HqcGZsDu2AKqVGXhCbKLsFlgVWg8,5921
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
@@ -87,7 +87,7 @@ oarepo_runtime/services/facets/enum.py,sha256=3LrShQIt9Vt5mkqUkc6FNxXCW5JEFdPwtG
87
87
  oarepo_runtime/services/facets/facet_groups_names.py,sha256=RR8eeUmD8d9t966JqfhslZnILn_xDSfYlL0hjyJT92Y,468
88
88
  oarepo_runtime/services/facets/max_facet.py,sha256=TZ4KMKKVJHzyU1KgNne4V7IMQPu1ALRpkz61Y0labrc,407
89
89
  oarepo_runtime/services/facets/nested_facet.py,sha256=y0xgjx37HsSj2xW7URxNemYTksD8hpPs7kOEfIBw22k,971
90
- oarepo_runtime/services/facets/params.py,sha256=5z8I4wKdp-7RJK4x6cSKE92fDJI8OkUz5JR5UKWAeYg,3564
90
+ oarepo_runtime/services/facets/params.py,sha256=NJLgqRYyamap6_ecpy6fgPpCl7JkcGPrY8xLl8jIZj8,3872
91
91
  oarepo_runtime/services/files/__init__.py,sha256=K8MStrEQf_BUhvzhwPTF93Hkhwrd1dtv35LDo7iZeTM,268
92
92
  oarepo_runtime/services/files/components.py,sha256=x6Wd-vvkqTqB1phj2a6h42DNQksN8PuR2XKaOGoNHfw,2400
93
93
  oarepo_runtime/services/files/service.py,sha256=8DH0Pefr9kilM2JnOb-UYsnqerE8Z1Mu4p6DOJ4j_ZU,608
@@ -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.39.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
120
- oarepo_runtime-1.5.39.dist-info/METADATA,sha256=RGiou0J7zgp38I8Amo2FdSs2OejAezp8e3j5eqInPPg,4680
121
- oarepo_runtime-1.5.39.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
122
- oarepo_runtime-1.5.39.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
123
- oarepo_runtime-1.5.39.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
124
- oarepo_runtime-1.5.39.dist-info/RECORD,,
119
+ oarepo_runtime-1.5.41.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
120
+ oarepo_runtime-1.5.41.dist-info/METADATA,sha256=Kx5C6qgpAbZSJ0XztooVip_UQC9mTSJtPgrOciV_DsM,4680
121
+ oarepo_runtime-1.5.41.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
122
+ oarepo_runtime-1.5.41.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
123
+ oarepo_runtime-1.5.41.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
124
+ oarepo_runtime-1.5.41.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5