[TASK] Remove deprecated _all field query for Elastic 6.x

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html
This commit is contained in:
Benjamin Serfhos 2018-10-03 10:59:54 +02:00
parent a93a7af27f
commit acac544f77
3 changed files with 26 additions and 14 deletions

View file

@ -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;

View file

@ -26,7 +26,8 @@ plugin {
searching {
fields {
query = _all
# Default query fields (leave empty for all)
query =
}
}
}

View file

@ -1,13 +1,20 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<div class="core-search">
<f:form name="searchRequest" object="{searchRequest}">
<f:form.textfield property="query"/>
<f:form.submit value="search"/>
</f:form>
<ul>
<f:for each="{searchResult}" as="result">
<f:link.page pageUid="{result.hit._source.pid}">
{result.id} [{result.type}] - {result.hit._source.search_title}
<li>
<f:link.page pageUid="{result.plainData.uid}">
[{result.type}:{result.plainData.uid}] - {result.plainData.search_title}
</f:link.page>
<br>
</li>
</f:for>
</ul>
</div>
</html>