Skip to content

Commit

Permalink
funders: tune search boost for acronyms
Browse files Browse the repository at this point in the history
* Add and `acronym.keyword` field to the funders mapping.
* Apply to funders the same field boosting as in affiliations.
  • Loading branch information
slint committed Sep 25, 2024
1 parent 7a47f6f commit 7e4d0fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 7 additions & 2 deletions invenio_vocabularies/contrib/funders/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""Vocabulary funders 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 @@
funder_fundref_doi_prefix = LocalProxy(
lambda: current_app.config["VOCABULARIES_FUNDER_DOI_PREFIX"]
)
localized_title = LocalProxy(lambda: f"title.{get_locale()}^20")


class FundersSearchOptions(SearchOptions):
Expand All @@ -30,9 +32,12 @@ class FundersSearchOptions(SearchOptions):
suggest_parser_cls = SuggestQueryParser.factory(
fields=[
"name^100",
"acronym.keyword^100",
"acronym^40",
localized_title,
"id^20",
"aliases^20",
"identifiers.identifier^10",
"acronym^10",
"aliases^10",
],
type="most_fields", # https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#multi-match-types
fuzziness="AUTO", # https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@
"acronym": {
"type": "text",
"analyzer": "accent_edge_analyzer",
"search_analyzer": "accent_analyzer"
"search_analyzer": "accent_analyzer",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "accent_normalizer"
}
}
},
"status": {
"type": "keyword"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@
"acronym": {
"type": "text",
"analyzer": "accent_edge_analyzer",
"search_analyzer": "accent_analyzer"
"search_analyzer": "accent_analyzer",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "accent_normalizer"
}
}
},
"status": {
"type": "keyword"
Expand Down

0 comments on commit 7e4d0fd

Please sign in to comment.