inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 62 forks source link

Define a different parser for the queries #328

Closed psaiz closed 9 months ago

psaiz commented 9 months ago

Package version (if known): 2.3.1

Describe the bug

The search factory might receive as an argument the query_parser that should be used. The issue is that, when this class is created, this argument is not specified, so there is no way of overwriting it.

I do want a different parser to be able to do an And of the terms, instead of an OR. I would like to be able to pass a function like:

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()