From acac544f77c4ba6c7c3ab5301c6f35f5894c0970 Mon Sep 17 00:00:00 2001 From: Benjamin Serfhos Date: Wed, 3 Oct 2018 10:59:54 +0200 Subject: [PATCH] [TASK] Remove deprecated _all field query for Elastic 6.x See: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html --- Classes/Domain/Search/QueryFactory.php | 8 +++-- Configuration/TypoScript/setup.txt | 3 +- .../Private/Templates/Search/Search.html | 29 ++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php index 310d34a..ef859e4 100644 --- a/Classes/Domain/Search/QueryFactory.php +++ b/Classes/Domain/Search/QueryFactory.php @@ -25,8 +25,8 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\ConfigurationUtility; use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\SearchRequestInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\ArrayUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; class QueryFactory { @@ -122,9 +122,13 @@ class QueryFactory $matchExpression = [ 'type' => 'most_fields', 'query' => $searchRequest->getSearchTerm(), - 'fields' => GeneralUtility::trimExplode(',', $this->configuration->get('searching.fields.query')), ]; + $fieldsToQuery = GeneralUtility::trimExplode(',', $this->configuration->getIfExists('searching.fields.query'), true); + if (!empty($fieldsToQuery)) { + $matchExpression['fields'] = $fieldsToQuery; + } + $minimumShouldMatch = $this->configuration->getIfExists('searching.minimumShouldMatch'); if ($minimumShouldMatch) { $matchExpression['minimum_should_match'] = $minimumShouldMatch; diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.txt index d3051c1..6144195 100644 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.txt @@ -26,7 +26,8 @@ plugin { searching { fields { - query = _all + # Default query fields (leave empty for all) + query = } } } diff --git a/Resources/Private/Templates/Search/Search.html b/Resources/Private/Templates/Search/Search.html index dc9e6b2..cfc737e 100644 --- a/Resources/Private/Templates/Search/Search.html +++ b/Resources/Private/Templates/Search/Search.html @@ -1,13 +1,20 @@ - + + - - - - - {result.id} [{result.type}] - {result.hit._source.search_title} - -
-
+