Commit 28e87a43 authored by Pablo Panero's avatar Pablo Panero
Browse files

search: add custom query parser to specify search field

parent 263b135f
......@@ -103,6 +103,7 @@ RECORDS_REST_ENDPOINTS = dict(
'application/json': ('invenio_records_rest.serializers'
......@@ -8,6 +8,7 @@
# or submit itself to any jurisdiction.
from elasticsearch_dsl import Q
from invenio_records_rest.query import default_search_factory
from invenio_search import RecordsSearch
from invenio_search.api import DefaultFilter
from flask import request, current_app
......@@ -75,6 +76,20 @@ def get_egroups():
return get_user_provides()
def search_factory(self, search, query_parser=None):
def _csas_query_parser(qstr=None):
"""Default parser that uses the Q() from elasticsearch_dsl."""
if qstr:
return Q('query_string', query=qstr, default_field='_search_all')
return Q()
return default_search_factory(self, search, _csas_query_parser)
csas_search_factory = search_factory
class RecordCERNSearch(RecordsSearch):
"""CERN search class."""
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment