2017-10-14 13:02:48 +02:00
.. _configuration_options_search:
Searching
=========
.. _size:
size
----
2017-10-29 12:25:25 +01:00
Defined how many search results should be fetched to be available in search result.
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
plugin.tx_searchcore.settings.searching.size = 50
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
Default is `` 10 `` .
2017-10-14 13:02:48 +02:00
.. _facets:
facets
------
2017-10-29 12:25:25 +01:00
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
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
category {
terms {
field = categories
}
}
month {
date_histogram {
field = released
interval = month
format = Y-MM-01
order {
_time = desc
}
2017-10-14 13:02:48 +02:00
}
2017-10-29 12:25:25 +01:00
}
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
The above example will provide a facet with options for all found `` categories `` results together
with a count. Also a facet for `` released `` will be provided.
2017-10-14 13:02:48 +02:00
.. _filter:
2017-10-29 12:25:25 +01:00
filter
------
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
Define filter that should be set for all search requests.
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
plugin.tx_searchcore.settings.searching.filter {
property = value
}
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
Also see :ref: `mapping.filter` to map incoming request information, e.g. from a `` select `` , to build
more complex filters.
2017-10-29 12:25:25 +01:00
For Elasticsearch the fields have to be filterable, e.g. need a mapping as `` keyword `` .
2017-10-14 13:02:48 +02:00
.. _minimumShouldMatch:
minimumShouldMatch
------------------
2018-03-08 08:17:41 +01:00
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
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
plugin.tx_searchcore.settings.searching.minimumShouldMatch = 50%
2017-10-14 13:02:48 +02:00
.. _boost:
boost
-----
2017-10-29 12:25:25 +01:00
Define fields that should boost the score for results.
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
plugin.tx_searchcore.settings.searching.boost {
search_title = 3
search_abstract = 1.5
}
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
For further information take a look at
https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_boosting_query_clauses.html
2017-10-14 13:02:48 +02:00
.. _fieldValueFactor:
fieldValueFactor
----------------
2018-03-08 08:17:41 +01:00
Define a field to use as a factor for scoring. The configuration is passed through to Elasticsearch
`` field_value_factor `` , see:
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#function-field-value-factor
2017-10-29 12:25:25 +01:00
Example::
plugin.tx_searchcore.settings.searching.field_value_factor {
field = rootlineLevel
modifier = reciprocal
factor = 2
missing = 1
}
.. _mapping.filter:
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:
.. code-block :: html
2018-03-08 08:17:41 +01:00
<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"')}
>{month.displayName -> f:format.date(format: '%B %Y')}</option>
</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"')}
>{month.displayName -> f:format.date(format: '%B %Y')}</option>
</f:if>
</f:for>
</select>
This will create a `` month `` filter with sub properties. To make this filter actually work, you
2017-10-29 12:25:25 +01:00
can add the following TypoScript, which will be added to the filter::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
mapping {
filter {
2018-03-06 16:34:59 +01:00
month {
type = range
field = released
raw {
format = yyyy-MM
}
2017-10-29 12:25:25 +01:00
fields {
2018-03-06 16:34:59 +01:00
gte = from
lte = to
2017-10-29 12:25:25 +01:00
}
}
}
}
`` fields `` has a special meaning here. This will actually map the properties of the filter to fields
2018-03-08 08:17:41 +01:00
in Elasticsearch. On the left hand side is the Elasticsearch field name, on the right side the one
submitted as a filter.
2017-10-29 12:25:25 +01:00
2018-03-08 08:17:41 +01:00
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.
2017-10-14 13:02:48 +02:00
2018-03-06 16:34:59 +01:00
Everything that is configured inside `` raw `` is passed, as is, to search service, e.g.
2018-03-08 08:17:41 +01:00
Elasticsearch.
2018-03-06 16:34:59 +01:00
2017-10-29 12:25:25 +01:00
.. _fields:
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
fields
------
2018-03-08 08:17:41 +01:00
Defines the fields to fetch and search from Elasticsearch. With the following sub keys:
2017-11-29 18:57:09 +01:00
2018-03-08 08:17:41 +01:00
`` query `` defines the fields to search in. 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 following is an example configuration::
2017-11-29 18:57:09 +01:00
fields {
query = _all, city
}
2018-03-08 08:17:41 +01:00
The following sub properties configure the fields to fetch from Elasticsearch:
2017-10-29 12:25:25 +01:00
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.
2018-03-08 08:17:41 +01:00
Second is `` script_fields `` , which allow you to configure scripted fields for Elasticsearch.
2017-10-29 12:25:25 +01:00
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
}
}
2017-10-14 13:02:48 +02:00
}
2017-10-29 12:25:25 +01:00
}
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
2018-03-08 08:17:41 +01:00
Elasticsearch, except each property is run through Fluidtemplate, to allow you to use information
2017-10-29 12:25:25 +01:00
from search request, e.g. to insert latitude and longitude from a filter, like in the above example.
.. _sort:
sort
----
Sort is handled like :ref: `fields` .
2017-10-14 13:02:48 +02:00
.. _mode:
2017-10-29 12:25:25 +01:00
mode
----
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Used by: Controller while preparing action.
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Define to switch from search to filter mode.
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
Example::
2017-10-14 13:02:48 +02:00
2017-10-29 12:25:25 +01:00
plugin.tx_searchcore.settings.searching {
mode = filter
}
2017-10-14 13:02:48 +02:00
2018-03-08 08:17:41 +01:00
Only `` filter `` is allowed as value, as `` search `` is default behaviour. Using `` filter `` will
trigger a search to provide data while visiting the page, possible :ref: `filter` allow you to build
pages like "News".
2018-03-06 10:47:14 +01:00
2018-03-08 08:17:41 +01:00
.. _searching_dataprocessing:
2018-03-06 10:47:14 +01:00
dataProcessing
--------------
2018-03-08 08:17:41 +01:00
Configure modifications on each document before returning search result.
For full documentation check out :ref: `dataprocessors` .