Skip to content

Commit

Permalink
Merge branch 'test' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dikastes authored Nov 12, 2024
2 parents 21d4a79 + 99a018d commit 9371f8d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Classes/Common/ElasticClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ protected function autoconfig (): ElasticClientBuilder {

private function setCaFilePath(): void
{
if ($this->extConf->get('elasticCaFileName') == '') {
if ($this->extConf->get('elasticCaFileFilePath') == '') {
$this->caFilePath = '';
return;
}

$this->caFilePath = $this->extConf->
sortKeysDesc()->
only('elasticCredentialsFilePath', 'elasticCaFileName')->
only('elasticCredentialsFilePath', 'elasticCaFileFilePath')->
implode('/');
}

Expand Down
23 changes: 21 additions & 2 deletions Classes/Common/QueryParamsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
]
]
]
]
Expand Down
5 changes: 1 addition & 4 deletions Classes/Services/ElasticSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}


}

0 comments on commit 9371f8d

Please sign in to comment.