diff --git a/Classes/Common/QueryParamsBuilder.php b/Classes/Common/QueryParamsBuilder.php index 2740f94..eeefd89 100644 --- a/Classes/Common/QueryParamsBuilder.php +++ b/Classes/Common/QueryParamsBuilder.php @@ -2,18 +2,27 @@ namespace Slub\LisztCommon\Common; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Utility\GeneralUtility; + class QueryParamsBuilder { //Todo: get Config for bibIndex, aggs etc. from extension config? - public static function createElasticParams(string $bibIndex, array $searchParams): array + public static function createElasticParams(array $searchParams): array { + $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('liszt_bibliography'); + $bibIndex = $extConf['elasticIndexName']; + $aggs = []; // TYPOSCRIPT stuff here + $params = [ 'index' => $bibIndex, 'body' => [ 'size' => 10, '_source' => ['itemType', 'tx_lisztcommon_header', 'tx_lisztcommon_body', 'tx_lisztcommon_footer'], - 'aggs' => [ + //'aggs' => $aggs + 'aggs' => + [ 'itemType' => [ 'terms' => [ 'field' => 'itemType.keyword', @@ -28,6 +37,16 @@ public static function createElasticParams(string $bibIndex, array $searchParams 'terms' => [ 'field' => 'date.keyword', ] + ], + 'language' => [ + 'terms' => [ + 'field' => 'language.keyword', + ] + ], + 'journalTitle' => [ + 'terms' => [ + 'field' => 'publicationTitle.keyword', + ] ] ] ] diff --git a/Classes/Services/ElasticSearchService.php b/Classes/Services/ElasticSearchService.php index dd3c363..f881bf7 100644 --- a/Classes/Services/ElasticSearchService.php +++ b/Classes/Services/ElasticSearchService.php @@ -41,17 +41,14 @@ public function getElasticInfo(): array return ($this->client->info()->asArray()); } - - public function search($searchParams): Collection { $this->init(); - $this->params = QueryParamsBuilder::createElasticParams($this->bibIndex, $searchParams); + $this->params = QueryParamsBuilder::createElasticParams($searchParams); // ToDo: handle exceptions! $response = $this->client->search($this->params); return new Collection($response->asArray()); } - }