Skip to content

Commit

Permalink
Merge pull request #8 from sitepark/feature/addStartLetterIndexField
Browse files Browse the repository at this point in the history
feat: add new indexField 'sp_startletter'
  • Loading branch information
hyra-soe authored Sep 16, 2024
2 parents f1b77a9 + 96b7e53 commit 40ca046
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Service/Indexer/IndexSchema2xDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IndexSchema2xDocument extends Document implements IndexDocument
public ?string $sp_name = null;
public ?string $sp_anchor = null;
public ?string $title = null;
public ?string $sp_startletter = null;
public ?string $description = null;
public ?string $sp_objecttype = null;
public ?bool $sp_canonical = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public function enrichDocument(

$doc->sp_archive = $base->getBool('archive');

$headline = $metadata->getString('headline')
?: $base->getString('teaser.headline')
$headline = $base->getString('teaser.headline')
?: $metadata->getString('headline')
?: $base->getString('title');
$doc->sp_title = $headline;

Expand All @@ -133,6 +133,8 @@ public function enrichDocument(
?: $base->getString('title');
$doc->sp_sortvalue = $sortHeadline;

$doc->sp_startletter = $base->getString('startletter');

/** @var string[] $keyword */
$keyword = $metadata->getArray('keywords');
$doc->keywords = $keyword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,18 @@ public function testEnrichContactPointContent(): void
);
}

public function testEnrichStartletter(): void
{
$doc = $this->enrichWithData(['base' => [
'startletter' => 'z',
]]);
$this->assertEquals(
'z',
$doc->sp_startletter,
'unexpected base.startletter',
);
}

private function enrichWithResource(
Resource $resource,
): IndexSchema2xDocument {
Expand Down

0 comments on commit 40ca046

Please sign in to comment.