mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-25 09:56:10 +01:00
FEATURE: Provide new feature to configure fields to search in
This enables you to search only in some fields. Also if some fields contain mapping, you can add them in addition to e.g. `_all`.
This commit is contained in:
parent
689d8f0c53
commit
02ef86b67b
3 changed files with 26 additions and 11 deletions
|
@ -99,20 +99,18 @@ class QueryFactory
|
|||
return;
|
||||
}
|
||||
|
||||
$query = ArrayUtility::setValueByPath(
|
||||
$query,
|
||||
'query.bool.must.0.match._all.query',
|
||||
$searchRequest->getSearchTerm()
|
||||
);
|
||||
$matchExpression = [
|
||||
'type' => 'most_fields',
|
||||
'query' => $searchRequest->getSearchTerm(),
|
||||
'fields' => GeneralUtility::trimExplode(',', $this->configuration->get('searching.fields.query')),
|
||||
];
|
||||
|
||||
$minimumShouldMatch = $this->configuration->getIfExists('searching.minimumShouldMatch');
|
||||
if ($minimumShouldMatch) {
|
||||
$query = ArrayUtility::setValueByPath(
|
||||
$query,
|
||||
'query.bool.must.0.match._all.minimum_should_match',
|
||||
$minimumShouldMatch
|
||||
);
|
||||
$matchExpression['minimum_should_match'] = $minimumShouldMatch;
|
||||
}
|
||||
|
||||
$query = ArrayUtility::setValueByPath($query, 'query.bool.must.0.multi_match', $matchExpression);
|
||||
}
|
||||
|
||||
protected function addBoosts(SearchRequestInterface $searchRequest, array &$query)
|
||||
|
|
|
@ -21,6 +21,12 @@ plugin {
|
|||
abstractFields = {$plugin.tx_searchcore.settings.indexing.pages.abstractFields}
|
||||
}
|
||||
}
|
||||
|
||||
searching {
|
||||
fields {
|
||||
query = _all
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,18 @@ filtering. This way you can use arbitrary filter names and map them to existing
|
|||
fields
|
||||
------
|
||||
|
||||
Defines the fields to fetch from elasticsearch. Two sub entries exist:
|
||||
Defines the fields to fetch and search from elasticsearch. With the following sub keys:
|
||||
|
||||
``query`` defines the fields to search in. Default is ``_all`` from 5.x times of elasticsearch.
|
||||
Configure a comma separated list of fields to search in. This is necessary if you have configured
|
||||
special mapping for some fields, or just want to search some fields.
|
||||
The most hits get ranked highest. The following is an example configuration::
|
||||
|
||||
fields {
|
||||
query = _all, city
|
||||
}
|
||||
|
||||
The following sub properties configure the fields to fetch from elasticsearch:
|
||||
|
||||
First ``stored_fields`` which is a list of comma separated fields which actually exist and will be
|
||||
added. Typically you will use ``_source`` to fetch the whole indexed fields.
|
||||
|
|
Loading…
Reference in a new issue