Allow "raw" configuration and support "range" type. Also prevent adding boosts if no search term was submitted which can be boosted. Resolves: #119
8.7 KiB
Searching
size
Used by: Elasticsearch connection while building search query.
Defined how many search results should be fetched to be available in search result.
Example:
plugin.tx_searchcore.settings.searching.size = 50
Default if not configured is 10.
facets
Used by: Elasticsearch connection while building search query.
Define aggregations for Elasticsearch, have a look at the official docs: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-terms-aggregation.html Currently only the term facet is provided.
Example:
plugin.tx_searchcore.settings.searching.facets {
contentTypes {
field = CType
}
}
The above example will provide a facet with options for all found
CType
results together with a count.
filter
Used by: While building search request.
Define filter that should be set for all requests.
Example:
plugin.tx_searchcore.settings.searching.filter {
property = value
}
For Elasticsearch the fields have to be filterable, e.g. need a
mapping as keyword
.
minimumShouldMatch
Used by: Elasticsearch connection while building search query.
Define the minimum match for Elasticsearch, have a look at the official docs: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-minimum-should-match.html
Example:
plugin.tx_searchcore.settings.searching.minimumShouldMatch = 50%
boost
Used by: Elasticsearch connection while building search query.
Define fields that should boost the score for results.
Example:
plugin.tx_searchcore.settings.searching.boost {
search_title = 3
search_abstract = 1.5
}
For further information take a look at https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_boosting_query_clauses.html
fieldValueFactor
Used by: Elasticsearch connection while building search query.
Define a field to use as a factor for scoring. The configuration is
passed through to elastic search field_value_factor
, see:
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#function-field-value-factor
Example:
plugin.tx_searchcore.settings.searching.field_value_factor {
field = rootlineLevel
modifier = reciprocal
factor = 2
missing = 1
}
mapping.filter
Allows to configure filter more in depth. If a filter with the given key exists, the TypoScript will be added.
E.g. you submit a filter in form of:
<f:comment>
Due to TYPO3 7.x fluid limitations, we build this input ourself.
No longer necessary in 8 and above</f:comment>
<select name="tx_searchcore_search[searchRequest][filter][month][from]" class="_control" >
<option value="">Month</option>
<f:for each="{searchResult.facets.month.options}" as="month">
<f:if condition="{month.count}">
<option
value="{month.displayName -> f:format.date(format: 'Y-m')}"
{f:if(condition: '{searchRequest.filter.month.from} == {month.displayName -> f:format.date(format: \'Y-m\')}', then: 'selected="true"')}
</option>
>{month.displayName -> f:format.date(format: '%B %Y')}</f:if>
</f:for>
</select>
<select name="tx_searchcore_search[searchRequest][filter][month][to]" class="_control" >
<option value="">Month</option>
<f:for each="{searchResult.facets.month.options}" as="month">
<f:if condition="{month.count}">
<option
value="{month.displayName -> f:format.date(format: 'Y-m')}"
{f:if(condition: '{searchRequest.filter.month.from} == {month.displayName -> f:format.date(format: \'Y-m\')}', then: 'selected="true"')}
</option>
>{month.displayName -> f:format.date(format: '%B %Y')}</f:if>
</f:for>
</select>
This will create a distance
filter with subproperties.
To make this filter actually work, you can add the following TypoScript,
which will be added to the filter:
mapping {
filter {
month {
type = range
field = released
raw {
format = yyyy-MM
}
fields {
gte = from
lte = to
}
}
}
}
fields
has a special meaning here. This will actually
map the properties of the filter to fields in elasticsearch. In above
example they do match, but you can also use different names in your
form. On the left hand side is the elasticsearch field name, on the
right side the one submitted as a filter.
The field
, in above example released
, will
be used as the elasticsearch field for filtering. This way you can use
arbitrary filter names and map them to existing elasticsearch
fields.
Everything that is configured inside raw
is passed, as
is, to search service, e.g. elasticsearch.
fields
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.
Second is script_fields
, which allow you to configure
scripted fields for elasticsearch. An example might look like the
following:
fields {
script_fields {
distance {
condition = {request.filter.distance.location}
script {
params {
lat = {request.filter.distance.location.lat -> f:format.number()}
lon = {request.filter.distance.location.lon -> f:format.number()}
}
lang = painless
inline = doc["location"].arcDistance(params.lat,params.lon) * 0.001
}
}
}
}
In above example we add a single script_field
called
distance
. We add a condition when this field should be
added. The condition will be parsed as Fluidtemplate and is casted to
bool via PHP. If the condition is true, or no condition
exists, the script_field
will be added to the query. The
condition
will be removed and everything else is submitted
one to one to elasticsearch, except each property is run through
Fluidtemplate, to allow you to use information from search request, e.g.
to insert latitude and longitude from a filter, like in the above
example.
sort
Sort is handled like fields
.
mode
Used by: Controller while preparing action.
Define to switch from search to filter mode.
Example:
plugin.tx_searchcore.settings.searching {
mode = filter
}
Only filter
is allowed as value. Will submit an empty
query to switch to filter mode.
dataProcessing
Used by: All connections while indexing, due to implementation inside
SearchService
.
Configure modifications on each document before returning search
result. Same as provided by TYPO3 for t3tsref:cobj-fluidtemplate
through t3tsref:cobj-fluidtemplate-properties-dataprocessing
.
All processors are applied in configured order. Allowing to work with already processed data.
Example:
plugin.tx_searchcore.settings.searching.dataProcessing {
1 = Codappix\SearchCore\DataProcessing\CopyToProcessor
1 {
to = search_spellcheck
}
2 = Codappix\SearchCore\DataProcessing\CopyToProcessor
2 {
to = search_all
}
}
The above example will copy all existing fields to the field
search_spellcheck
. Afterwards all fields, including
search_spellcheck
will be copied to
search_all
.
Also data processors are available while indexing too, see dataProcessing
.