Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

44 small changes #47

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Classes/Processing/BibElasticMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ] ],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe simple [ 'type' => 'keyword'] would be sufficient

'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' => [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change creatorType from type keyword to text and creatorType.keyword means you will also textsearch in creatorType?
(the key for the facette in serachresults will probably change from creatorType to creatorType.keyword)

'keyword' => [
'type' => 'keyword', 'ignore_above' => 256
]
]
],
'firstName' => [
'type' => 'text',
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' ]
];
}
28 changes: 16 additions & 12 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
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
Loading