From 5ddcd5bfdd24fc0253a890970b9dfdf73b31c2f0 Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Wed, 11 Dec 2024 12:02:52 +0530 Subject: [PATCH] Added alternative title for ascii folding --- doajtest/fixtures/v2/journals.py | 17 ++++++++++------- doajtest/unit/test_query.py | 9 ++++++++- portality/settings.py | 4 +++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/doajtest/fixtures/v2/journals.py b/doajtest/fixtures/v2/journals.py index 19cdf4afe..9986789ab 100644 --- a/doajtest/fixtures/v2/journals.py +++ b/doajtest/fixtures/v2/journals.py @@ -45,15 +45,18 @@ def make_journal_form_info(): return deepcopy(JOURNAL_FORM_EXPANDED) @staticmethod - def make_journal_with_data(title=None, publisher_name=None, country=None, in_doaj=True): + def make_journal_with_data(**data): journal = deepcopy(JOURNAL_SOURCE) + in_doaj = data['in_doaj'] if'in_doaj' in data else True journal['admin']['in_doaj'] = in_doaj - if title: - journal["bibjson"]["title"] = title - if publisher_name: - journal["bibjson"]["publisher"]["name"] = publisher_name - if country: - journal["bibjson"]["publisher"]["country"] = country + if 'title' in data: + journal["bibjson"]["title"] = data['title'] + if 'publisher_name' in data: + journal["bibjson"]["publisher"]["name"] = data['publisher_name'] + if 'country' in data: + journal["bibjson"]["publisher"]["country"] = data['country'] + if 'alternative_title' in data: + journal["bibjson"]["alternative_title"] = data['alternative_title'] return journal @staticmethod diff --git a/doajtest/unit/test_query.py b/doajtest/unit/test_query.py index a40f8d1b8..454e32e20 100644 --- a/doajtest/unit/test_query.py +++ b/doajtest/unit/test_query.py @@ -698,7 +698,8 @@ def test_journal_query_ascii_folding_data(self): self.journal = models.Journal(**JournalFixtureFactory .make_journal_with_data(title="Kadınlarının sağlık", publisher_name="Ankara Üniversitesi", - country="Türkiye", )) + country="Türkiye", + alternative_title="Dirasat: Shariía and Law Sciences")) self.journal.save(blocking=True) qsvc = QueryService() @@ -725,6 +726,12 @@ def test_journal_query_ascii_folding_data(self): assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + # check alternative title + res = qsvc.search('query', 'journal', raw_query("Shariia"), + account=None, additional_parameters={}) + + assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + def test_application_query_ascii_folding_data(self): acc = models.Account(**AccountFixtureFactory.make_managing_editor_source()) application = models.Application(**ApplicationFixtureFactory diff --git a/portality/settings.py b/portality/settings.py index 61c6aa2b8..c50533034 100644 --- a/portality/settings.py +++ b/portality/settings.py @@ -989,8 +989,10 @@ JOURNAL_EXCEPTION_MAPPING = { "bibjson.title" : {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED}, + "bibjson.alternative_title" : {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED}, "bibjson.publisher.name" : {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED}, - "index.country" : {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED} + "index.country" : {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED}, + "index.title": {**DATAOBJ_TO_MAPPING_DEFAULTS["unicode"], **ASCII_FOLDED} } ARTICLE_EXCEPTION_MAPPING = {