oarepo-runtime 1.5.37__py3-none-any.whl → 1.5.38__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.
- oarepo_runtime/services/search.py +24 -3
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/RECORD +7 -7
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.37.dist-info → oarepo_runtime-1.5.38.dist-info}/top_level.txt +0 -0
@@ -12,6 +12,8 @@ from invenio_records_resources.services.records.params import (
|
|
12
12
|
SortParam,
|
13
13
|
)
|
14
14
|
from invenio_records_resources.services.records.queryparser import SuggestQueryParser
|
15
|
+
from invenio_search.engine import dsl
|
16
|
+
|
15
17
|
|
16
18
|
# TODO: integrate this to invenio_records_resources.services.records and remove SearchOptions class
|
17
19
|
from oarepo_runtime.i18n import lazy_gettext as _
|
@@ -25,6 +27,27 @@ except ImportError:
|
|
25
27
|
from invenio_i18n.babel import get_locale
|
26
28
|
|
27
29
|
|
30
|
+
class FuzzySuggestQueryParser(SuggestQueryParser):
|
31
|
+
def __init__(self, identity=None, extra_params=None, **kwargs):
|
32
|
+
"""Constructor."""
|
33
|
+
super().__init__(identity=identity, extra_params=extra_params)
|
34
|
+
self.fields = self.extra_params.get("fields", [])
|
35
|
+
self.extra_params.setdefault("type", "bool_prefix")
|
36
|
+
|
37
|
+
def parse(self, query_str):
|
38
|
+
"""Parse the query."""
|
39
|
+
# default behavior
|
40
|
+
multi_match_with_bool_prefix = dsl.Q(
|
41
|
+
"multi_match", query=query_str, **self.extra_params
|
42
|
+
)
|
43
|
+
# fuzziness does not seem to work with bool_prefix multimatch query, so we turn this into
|
44
|
+
# should multi match query with two clauses
|
45
|
+
multi_match_fuzzy = dsl.Q(
|
46
|
+
"multi_match", query=query_str, fields=self.fields, fuzziness="AUTO"
|
47
|
+
)
|
48
|
+
return dsl.Q("bool", should=[multi_match_with_bool_prefix, multi_match_fuzzy])
|
49
|
+
|
50
|
+
|
28
51
|
class SearchOptions(InvenioSearchOptions):
|
29
52
|
params_interpreters_cls = [
|
30
53
|
QueryStrParam,
|
@@ -114,9 +137,7 @@ class ICUSuggestParser:
|
|
114
137
|
f"{fld.field}._index_prefix^{fld.boost * fld.boost_prefix}"
|
115
138
|
)
|
116
139
|
|
117
|
-
return
|
118
|
-
fields=fields,
|
119
|
-
)
|
140
|
+
return FuzzySuggestQueryParser.factory(fields=fields)
|
120
141
|
|
121
142
|
|
122
143
|
@dataclasses.dataclass
|
@@ -71,7 +71,7 @@ oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
71
71
|
oarepo_runtime/services/components.py,sha256=9wt9CmoCFA8Utbb8eNA-Mvzo5LCApHT9zHpWIWZNyXY,1506
|
72
72
|
oarepo_runtime/services/generators.py,sha256=V582uA813AIXnFhzqUwakmDgBOI1SQe3XZeJtUXNbwM,872
|
73
73
|
oarepo_runtime/services/results.py,sha256=ocEXdTl1Gdu-OmAkmB98Yf5t4IwsbESDf1r3GV73FTg,2706
|
74
|
-
oarepo_runtime/services/search.py,sha256=
|
74
|
+
oarepo_runtime/services/search.py,sha256=eVOJ5xI9dKAVlWDM0E8mg1bYS3pGxsdpW8kTYNl5wRk,6228
|
75
75
|
oarepo_runtime/services/config/__init__.py,sha256=SCqww5sV8qh3gmev6TE8EyJbD58juIEDCm_7MEHxtSg,440
|
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
|
@@ -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.
|
120
|
-
oarepo_runtime-1.5.
|
121
|
-
oarepo_runtime-1.5.
|
122
|
-
oarepo_runtime-1.5.
|
123
|
-
oarepo_runtime-1.5.
|
124
|
-
oarepo_runtime-1.5.
|
119
|
+
oarepo_runtime-1.5.38.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
120
|
+
oarepo_runtime-1.5.38.dist-info/METADATA,sha256=9jbrRNAbeANj8jeFjvvqXPethvs0SoHPechzSEdX7Rs,4680
|
121
|
+
oarepo_runtime-1.5.38.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
122
|
+
oarepo_runtime-1.5.38.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
|
123
|
+
oarepo_runtime-1.5.38.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
124
|
+
oarepo_runtime-1.5.38.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|