Skip to content

Commit

Permalink
subjects: add subject to search fields
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba authored and slint committed Nov 15, 2024
1 parent e9ec778 commit c4f9d24
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion invenio_vocabularies/contrib/subjects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""Subjects configuration."""

from flask import current_app
from invenio_i18n import get_locale
from invenio_i18n import lazy_gettext as _
from invenio_records_resources.services import SearchOptions
from invenio_records_resources.services.records.components import DataComponent
Expand All @@ -22,6 +23,7 @@
subject_schemes = LocalProxy(
lambda: current_app.config["VOCABULARIES_SUBJECTS_SCHEMES"]
)
localized_title = LocalProxy(lambda: f"title.{get_locale()}^20")


class SubjectsSearchOptions(SearchOptions):
Expand All @@ -30,7 +32,8 @@ class SubjectsSearchOptions(SearchOptions):
suggest_parser_cls = FilteredSuggestQueryParser.factory(
filter_field="scheme",
fields=[ # suggest fields
"title.*^100",
"subject^100",
localized_title,
"synonyms^20",
],
)
Expand Down

0 comments on commit c4f9d24

Please sign in to comment.