Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query: use an AND parser instead of OR #3482

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cernopendata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from invenio_records_rest.config import RECORDS_REST_ENDPOINTS
from invenio_records_rest.facets import nested_filter, range_filter, terms_filter
from invenio_records_rest.utils import allow_all
from invenio_search.engine import dsl
from urllib3.exceptions import InsecureRequestWarning

from cernopendata.modules.pages.config import *
Expand Down Expand Up @@ -210,10 +211,19 @@

RECORDS_REST_ENDPOINTS["recid"]["search_index"] = "records"


def _query_parser_and(qstr=None):
"""Parser that uses the Q() with AND from search engine dsl."""
if qstr:
return dsl.Q("query_string", query=qstr, default_operator="AND")
return dsl.Q()


RECORDS_REST_ENDPOINTS["recid"].update(
{
# 'search_factory_imp': 'cernopendata.modules.records.search.query'
# ':cernopendata_search_factory',
"search_query_parser": _query_parser_and,
"pid_minter": "cernopendata_recid_minter",
"pid_fetcher": "cernopendata_recid_fetcher",
"record_class": _Record,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"invenio-jsonschemas==1.1.3",
"invenio-pidstore==1.3.1",
# This one requires the nested_filter
"invenio-records-rest[datacite]==2.3.1",
"invenio-records-rest[datacite]==2.4.0",
"invenio-records-ui==1.2.0",
"invenio-records==2.1.0",
"invenio-search-ui==2.8.2",
Expand Down
Loading