From 28aaf7f38a731452e14b0fe41b2e2cf8491e735a Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 10 Dec 2024 18:29:54 +0100 Subject: [PATCH 1/5] Add colon and add in to journal article footer --- Classes/Processing/BibEntryConfig.php | 161 ++++++++++++++------------ 1 file changed, 87 insertions(+), 74 deletions(-) diff --git a/Classes/Processing/BibEntryConfig.php b/Classes/Processing/BibEntryConfig.php index 33a84d5..108d7f4 100644 --- a/Classes/Processing/BibEntryConfig.php +++ b/Classes/Processing/BibEntryConfig.php @@ -35,6 +35,7 @@ class BibEntryConfig 'separator' => ', ' ] ]; + const EDITOR = [ 'compound' => [ 'fields' => [ @@ -55,6 +56,7 @@ class BibEntryConfig 'separator' => ', ' ] ]; + const TRANSLATOR = [ 'compound' => [ 'fields' => [ @@ -75,55 +77,65 @@ class BibEntryConfig 'separator' => ', ' ] ]; + const TITLE = [ 'field' => 'title' ]; + const PUBLICATION_TITLE = [ 'field' => 'publicationTitle', 'conditionField' => 'publicationTitle', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const BOOK_TITLE = [ 'field' => 'bookTitle', 'conditionField' => 'bookTitle', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const UNIVERSITY = [ 'field' => 'university', 'conditionField' => 'university', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const VOLUME = [ 'field' => 'volume', 'conditionField' => 'volume', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const ISSUE = [ 'field' => 'issue', 'conditionField' => 'issue', 'conditionValue' => '', 'conditionRelation' => 'neq' ]; + const PLACE = [ 'field' => 'place', 'conditionField' => 'place', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const DATE = [ 'field' => 'date', 'conditionField' => 'date', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const PAGES = [ 'field' => 'pages', 'conditionField' => 'pages', 'conditionValue' => '', 'conditionRelation' => 'neq', ]; + const NUMBER_OF_VOLUMES = [ 'field' => 'numberOfVolumes', 'conditionField' => 'numberOfVolumes', @@ -131,6 +143,79 @@ class BibEntryConfig 'conditionRelation' => 'neq', ]; + const SEARCHABLE_FIELDS = [ + [ + 'compound' => [ + 'fields' => [ + [ + 'field' => 'firstName', + 'conditionField' => 'creatorType', + 'conditionValue' => 'author', + 'conditionRelation' => 'eq' + ], + [ + 'field' => 'lastName', + 'conditionField' => 'creatorType', + 'conditionValue' => 'author', + 'conditionRelation' => 'eq' + ] + ], + 'field' => 'creators', + 'separator' => ' ', + 'postfix' => ' ' + ] + ], + [ + 'field' => 'title', + 'postfix' => ' ' + ], + [ + 'field' => 'university', + 'postfix' => ' ' + ], + [ + 'field' => 'bookTitle', + 'postfix' => ' ' + ], + [ + 'field' => 'series', + 'postfix' => ' ' + ], + [ + 'field' => 'publicationTitle', + 'postfix' => ' ' + ], + [ + 'field' => 'place', + 'postfix' => ' ' + ], + [ + 'field' => 'date', + 'postfix' => ' ' + ] + ]; + + const BOOSTED_FIELDS = [ + [ + 'compound' => [ + 'fields' => [ + [ + 'field' => 'lastName', + 'conditionField' => 'creatorType', + 'conditionValue' => 'author', + 'conditionRelation' => 'eq' + ] + ], + 'field' => 'creators', + 'separator' => ' ', + 'reverseFirst' => true, + 'postfix' => ' ' + ] + ], + [ 'field' => 'title' ], + [ 'field' => 'date' ] + ]; + public static function getAuthorHeader(): array { return [ self::AUTHOR ]; @@ -149,7 +234,7 @@ public static function getBody(): array public static function getArticleFooter(): array { return [ - self::postfix(self::PUBLICATION_TITLE, ' '), + self::circumfix(self::PUBLICATION_TITLE, 'in: ', ' '), self::postfix(self::VOLUME, ' '), self::circumfix(self::DATE, '(', '), '), self::circumfix(self::ISSUE, 'Nr. ', ', '), @@ -160,7 +245,7 @@ public static function getArticleFooter(): array public static function getBookSectionFooter(): array { return [ - self::circumfix(self::BOOK_TITLE, 'In ', ', '), + self::circumfix(self::BOOK_TITLE, 'in: ', ', '), self::circumfix(self::EDITOR, 'hg. von ', ', '), self::circumfix(self::TRANSLATOR, 'übers. von ', ', '), self::postfix(self::NUMBER_OF_VOLUMES, 'Bde., '), @@ -236,76 +321,4 @@ private static function surroundComma(array $field): array { return self::comma(self::surround($field)); } - - const SEARCHABLE_FIELDS = [ - [ - 'compound' => [ - 'fields' => [ - [ - 'field' => 'firstName', - 'conditionField' => 'creatorType', - 'conditionValue' => 'author', - 'conditionRelation' => 'eq' - ], - [ - 'field' => 'lastName', - 'conditionField' => 'creatorType', - 'conditionValue' => 'author', - 'conditionRelation' => 'eq' - ] - ], - 'field' => 'creators', - 'separator' => ' ', - 'postfix' => ' ' - ] - ], - [ - 'field' => 'title', - 'postfix' => ' ' - ], - [ - 'field' => 'university', - 'postfix' => ' ' - ], - [ - 'field' => 'bookTitle', - 'postfix' => ' ' - ], - [ - 'field' => 'series', - 'postfix' => ' ' - ], - [ - 'field' => 'publicationTitle', - 'postfix' => ' ' - ], - [ - 'field' => 'place', - 'postfix' => ' ' - ], - [ - 'field' => 'date', - 'postfix' => ' ' - ] - ]; - const BOOSTED_FIELDS = [ - [ - 'compound' => [ - 'fields' => [ - [ - 'field' => 'lastName', - 'conditionField' => 'creatorType', - 'conditionValue' => 'author', - 'conditionRelation' => 'eq' - ] - ], - 'field' => 'creators', - 'separator' => ' ', - 'reverseFirst' => true, - 'postfix' => ' ' - ] - ], - [ 'field' => 'title' ], - [ 'field' => 'date' ] - ]; } From 40ae1824c97961d344355ec00541d77982159b3e Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 10 Dec 2024 20:58:33 +0100 Subject: [PATCH 2/5] Reorder facets and remove translators from creator facet --- Configuration/TypoScript/setup.typoscript | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index ce4a293..208f40f 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -41,29 +41,33 @@ plugin.tx_lisztcommon_searchlisting { type = terms } 1 { - field = place - type = terms - } - 2 { - field = date - type = terms - } - 3 { - field = publicationTitle - type = terms - } - 4 { field = creators type = nested script ( String firstName = doc['creators.firstName.keyword'].size() > 0 ? doc['creators.firstName.keyword'].value : ''; String lastName = doc['creators.lastName.keyword'].size() > 0 ? doc['creators.lastName.keyword'].value : ''; + String type = doc['creators.creatorType.keyword'].size() > 0 ? doc['creators.creatorType.keyword'].value : ''; + if (type == 'translator') { + return null; + } if (firstName == '' && lastName == '') { return null; } return (firstName + ' ' + lastName).trim(); ) } + 2 { + field = date + type = terms + } + 3 { + field = language + type = terms + } + 4 { + field = publicationTitle + type = terms + } } } } From d8efe57d803d5e072ed492d8543324f6f6ae2f96 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 10 Dec 2024 21:58:56 +0100 Subject: [PATCH 3/5] Add facet fields --- Classes/Processing/BibElasticMapping.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Classes/Processing/BibElasticMapping.php b/Classes/Processing/BibElasticMapping.php index 8f897c4..724172e 100644 --- a/Classes/Processing/BibElasticMapping.php +++ b/Classes/Processing/BibElasticMapping.php @@ -15,22 +15,28 @@ public static function getMappingParams(string $index): array 'mappings' => [ 'dynamic' => false, 'properties' => [ + 'itemType' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'version' => [ 'type' => 'long' ], 'title' => [ 'type' => 'text'], 'university' => [ 'type' => 'text'], 'bookTitle' => [ 'type' => 'text'], 'series' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'publicationTitle' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], + 'language' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'place' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'date' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'archiveLocation' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], - 'itemType' => [ 'type' => 'keyword'], 'journalTitle' => [ 'type' => 'keyword'], 'creators' => [ 'type' => 'nested', 'properties' => [ 'creatorType' => [ - 'type' => 'keyword' + 'type' => 'text', + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', 'ignore_above' => 256 + ] + ] ], 'firstName' => [ 'type' => 'text', From ea8d019525cdf3fcba4d9f5735ebe38e900e5613 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 10 Dec 2024 22:02:28 +0100 Subject: [PATCH 4/5] Adjust test --- Tests/Unit/Processing/BibEntryProcessorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Unit/Processing/BibEntryProcessorTest.php b/Tests/Unit/Processing/BibEntryProcessorTest.php index 08f7437..68b2fff 100644 --- a/Tests/Unit/Processing/BibEntryProcessorTest.php +++ b/Tests/Unit/Processing/BibEntryProcessorTest.php @@ -249,7 +249,7 @@ public function bookSectionFooterIsProcessedCorrectly(): void { $bookSection = $this->subject->process($this->exampleBookSectionArray, new Collection(), new Collection()); $expected = Str::of( - 'In ' . $this->bookTitle . ', ' . + 'in: ' . $this->bookTitle . ', ' . 'hg. von ' . $this->editorFirstName . ' ' . $this->editorLastName . ', ' . 'übers. von ' . $this->translatorFirstName . ' ' . $this->translatorLastName . ', ' . $this->numberOfVolumes . 'Bde., ' . @@ -269,7 +269,7 @@ public function articleFooterIsProcessedCorrectly(): void { $article = $this->subject->process($this->exampleArticleArray, new Collection(), new Collection()); $expected = Str::of( - $this->bookTitle . ' ' . + 'in: ' . $this->bookTitle . ' ' . $this->volume . ' (' . $this->date . '), Nr. ' . $this->issue . ', ' . From 9b22676c021b00ff36198402f7c13bb9dd8bef15 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Wed, 11 Dec 2024 11:14:53 +0100 Subject: [PATCH 5/5] Adjust mapping --- Classes/Processing/BibElasticMapping.php | 11 +++-------- Configuration/TypoScript/setup.typoscript | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Classes/Processing/BibElasticMapping.php b/Classes/Processing/BibElasticMapping.php index 724172e..c911930 100644 --- a/Classes/Processing/BibElasticMapping.php +++ b/Classes/Processing/BibElasticMapping.php @@ -15,14 +15,14 @@ public static function getMappingParams(string $index): array 'mappings' => [ 'dynamic' => false, 'properties' => [ - 'itemType' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], + 'itemType' => [ 'type' => 'keyword' ], 'version' => [ 'type' => 'long' ], 'title' => [ 'type' => 'text'], 'university' => [ 'type' => 'text'], 'bookTitle' => [ 'type' => 'text'], 'series' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'publicationTitle' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], - 'language' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], + 'language' => [ 'type' => 'keyword' ], 'place' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'date' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], 'archiveLocation' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', 'ignore_above' => 256 ] ] ], @@ -31,12 +31,7 @@ public static function getMappingParams(string $index): array 'type' => 'nested', 'properties' => [ 'creatorType' => [ - 'type' => 'text', - 'fields' => [ - 'keyword' => [ - 'type' => 'keyword', 'ignore_above' => 256 - ] - ] + 'type' => 'keyword' ], 'firstName' => [ 'type' => 'text', diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 208f40f..e79a435 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -38,7 +38,7 @@ plugin.tx_lisztcommon_searchlisting { filters { 0 { field = itemType - type = terms + type = keyword } 1 { field = creators @@ -46,7 +46,7 @@ plugin.tx_lisztcommon_searchlisting { script ( String firstName = doc['creators.firstName.keyword'].size() > 0 ? doc['creators.firstName.keyword'].value : ''; String lastName = doc['creators.lastName.keyword'].size() > 0 ? doc['creators.lastName.keyword'].value : ''; - String type = doc['creators.creatorType.keyword'].size() > 0 ? doc['creators.creatorType.keyword'].value : ''; + String type = doc['creators.creatorType'].size() > 0 ? doc['creators.creatorType'].value : ''; if (type == 'translator') { return null; } @@ -62,7 +62,7 @@ plugin.tx_lisztcommon_searchlisting { } 3 { field = language - type = terms + type = keyword } 4 { field = publicationTitle