Skip to content

Commit

Permalink
Merge pull request #47 from slub/44-small-changes
Browse files Browse the repository at this point in the history
44 small changes
  • Loading branch information
dikastes authored Dec 11, 2024
2 parents 840b887 + 9b22676 commit 4bf7f7e
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 90 deletions.
3 changes: 2 additions & 1 deletion Classes/Processing/BibElasticMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ public static function getMappingParams(string $index): array
'mappings' => [
'dynamic' => false,
'properties' => [
'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' => '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 ] ] ],
'itemType' => [ 'type' => 'keyword'],
'journalTitle' => [ 'type' => 'keyword'],
'creators' => [
'type' => 'nested',
Expand Down
161 changes: 87 additions & 74 deletions Classes/Processing/BibEntryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BibEntryConfig
'separator' => ', '
]
];

const EDITOR = [
'compound' => [
'fields' => [
Expand All @@ -55,6 +56,7 @@ class BibEntryConfig
'separator' => ', '
]
];

const TRANSLATOR = [
'compound' => [
'fields' => [
Expand All @@ -75,62 +77,145 @@ 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',
'conditionValue' => '',
'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 ];
Expand All @@ -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. ', ', '),
Expand All @@ -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., '),
Expand Down Expand Up @@ -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' ]
];
}
30 changes: 17 additions & 13 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,36 @@ plugin.tx_lisztcommon_searchlisting {
filters {
0 {
field = itemType
type = terms
type = keyword
}
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'].size() > 0 ? doc['creators.creatorType'].value : '';
if (type == 'translator') {
return null;
}
if (firstName == '' && lastName == '') {
return null;
}
return (firstName + ' ' + lastName).trim();
)
}
2 {
field = date
type = terms
}
3 {
field = language
type = keyword
}
4 {
field = publicationTitle
type = terms
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Processing/BibEntryProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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., ' .
Expand All @@ -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 . ', ' .
Expand Down

0 comments on commit 4bf7f7e

Please sign in to comment.