Skip to content

Commit

Permalink
search_permissions: modify extra params for es query via config
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Jun 21, 2024
1 parent dcbab6e commit 64da3cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions invenio_app_ils/search_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def ils_search_factory(self, search, query_parser=None, validator=None):
:returns: Tuple with search instance and URL arguments.
"""

def _query_parser(search, qstr=None, query_parser=None):
def _query_parser(search, qstr=None, query_params_modifier=None):
"""Default parser that uses the Q() from invenio_search.engine.dsl."""
if qstr:
boosted = getattr(search, "boosted_fields", [])
Expand All @@ -74,8 +74,8 @@ def _query_parser(search, qstr=None, query_parser=None):
# parsing exception on data fields, see known issues
# https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-7.1.1.html # noqa
extra_params["lenient"] = True
if query_parser:
return query_parser(qstr, extra_params)
if query_params_modifier:
query_params_modifier(extra_params)
return dsl.Q("query_string", query=qstr, **extra_params)
return dsl.Q()

Expand All @@ -86,7 +86,7 @@ def _query_parser(search, qstr=None, query_parser=None):

if validator:
search, query_string = validator(search, query_string)
query = _query_parser(search, qstr=query_string, query_parser=query_parser)
query = _query_parser(search, qstr=query_string, query_params_modifier=query_parser)

try:
search = search.query(query)
Expand Down

0 comments on commit 64da3cd

Please sign in to comment.