text: # -*- coding: utf-8 -*-
  #
  # Copyright (C) 2022 CERN.
  #
  # Invenio-Vocabularies is free software; you can redistribute it and/or
  # modify it under the terms of the MIT License; see LICENSE file for more
  # details.
  
  """Vocabulary funders configuration."""
  
  from flask import current_app
  from flask_babelex import lazy_gettext as _
  from invenio_records_resources.services import SearchOptions
  from invenio_records_resources.services.records.components import DataComponent
  from invenio_records_resources.services.records.params import \
      SuggestQueryParser
  from werkzeug.local import LocalProxy
  
  from ...services.components import ModelPIDComponent
  
  funder_schemes = LocalProxy(
      lambda: current_app.config["VOCABULARIES_FUNDER_SCHEMES"]
  )
  
  funder_fundref_doi_prefix = LocalProxy(
      lambda: current_app.config["VOCABULARIES_FUNDER_DOI_PREFIX"]
  )
  
  
  class FundersSearchOptions(SearchOptions):
      """Search options."""
  
      suggest_parser_cls = SuggestQueryParser.factory(
          fields=[
              'name^100',
              'title.*^5',
              'title.*._2gram',
              'title.*._3gram',
          ]
      )
  
      sort_default = 'bestmatch'
  
      sort_default_no_query = 'name'
  
      sort_options = {
          "bestmatch": dict(
              title=_('Best match'),
              fields=['_score'],  # ES defaults to desc on `_score` field
          ),
          "name": dict(
              title=_('Name'),
              fields=['name_sort'],
          ),
          "newest": dict(
              title=_('Newest'),
              fields=['-created'],
          ),
          "oldest": dict(
              title=_('Oldest'),
              fields=['created'],
          ),
      }
  
  
  service_components = [
      # Order of components are important!
      DataComponent,
      ModelPIDComponent,
  ]
  