-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move ElasticSearchService from liszt_bibliography to liszt_common
- Loading branch information
thomas-sc
committed
Oct 9, 2024
1 parent
050b46e
commit 6df21ae
Showing
23 changed files
with
520 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Slub\LisztCommon\Common; | ||
|
||
class QueryParameterProcessing | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace Slub\LisztCommon\Interfaces; | ||
use Illuminate\Support\Collection; | ||
|
||
|
||
interface ElasticSearchServiceInterface | ||
{ | ||
public function init(): bool; | ||
|
||
public function getElasticInfo(): array; | ||
|
||
public function search(): Collection; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
|
||
namespace Slub\LisztCommon\Services; | ||
|
||
use Elastic\Elasticsearch\Client; | ||
use Elastic\Elasticsearch\Response\Elasticsearch; | ||
use Http\Promise\Promise; | ||
use Illuminate\Support\Collection; | ||
use Slub\LisztCommon\Common\ElasticClientBuilder; | ||
use Slub\LisztCommon\Interfaces\ElasticSearchServiceInterface; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; | ||
|
||
|
||
|
||
class ElasticSearchService implements ElasticSearchServiceInterface | ||
{ | ||
|
||
protected ?Client $client = null; | ||
protected string $bibIndex; | ||
protected string $localeIndex; | ||
|
||
// Todo: Enable Elasticsearch Security: built-in security features are not enabled. | ||
public function init(): bool | ||
{ | ||
$this->client = ElasticClientBuilder::getClient(); | ||
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('liszt_bibliography'); | ||
$this->bibIndex = $extConf['elasticIndexName']; | ||
$this->localeIndex = $extConf['elasticLocaleIndexName']; | ||
return true; | ||
} | ||
|
||
public function getElasticInfo(): array | ||
{ | ||
$this->init(); | ||
return ($this->client->info()->asArray()); | ||
} | ||
|
||
public function search(): Collection | ||
{ | ||
$this->init(); | ||
$params = [ | ||
'index' => $this->bibIndex, | ||
'body' => [ | ||
'query' => [ | ||
'match_all' => new \stdClass() | ||
], | ||
'size' => 10, | ||
'_source' => ['itemType', 'title', 'creators', 'pages','date','language', 'localizedCitations'], | ||
'aggs' => [ | ||
'itemType' => [ | ||
'terms' => [ | ||
'field' => 'itemType.keyword', | ||
] | ||
], | ||
'place' => [ | ||
'terms' => [ | ||
'field' => 'place.keyword', | ||
] | ||
] | ||
] | ||
] | ||
]; | ||
// ToDo: handle exceptions! | ||
$response = $this->client->search($params); | ||
return new Collection($response->asArray()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Slub\LisztCommon\ViewHelpers; | ||
|
||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Type\File\ImageInfo; | ||
|
||
|
||
|
||
final class GetQueryParamsViewHelper extends AbstractViewHelper | ||
{ | ||
|
||
|
||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): array | ||
{ | ||
|
||
/** @var RenderingContext $renderingContext */ | ||
$request = $renderingContext->getRequest(); | ||
|
||
|
||
return $request->getQueryParams(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.