Field Type searching¶
Fields, or a custom Field Type, might contain or maintain data relevant for user searches. To make the search engine aware of the data in your Field Type you need to implement an additional interface and register the implementation.
Ibexa\Contracts\Core\FieldType\Indexable interface defines the methods below which are required if the Field Type provides data relevant to search engines.
getIndexData(Field $field, FieldDefinition $fieldDefinition)¶
This method returns the actual index data for the provided
Ibexa\Contracts\Core\Persistence\Content\Field. The index data consists of an array of
Ibexa\Contracts\Core\Search\Field instances. They are described below in further detail.
To be able to query data properly an indexable Field Type also is required to return search specification. You must return an associative array of
Ibexa\Contracts\Core\Search\FieldType instances from this method, which could look like:
1 2 3 4
This example from the
Url Field Type shows that the Field Type will always return two indexable values, both strings. They have the names
This method retrieves the name of the default Field to be used for matching. As Field Types can index multiple Fields (see MapLocation Field Type's implementation of this interface), this method is used to define the default field for matching. The default Field is typically used by the
Field Search Criterion.
This method gets name of the default Field to be used for sorting. As Field Types can index multiple Fields (see MapLocation Field Type's implementation of this interface), this method is used to define default field for sorting. Default Field is typically used by the
Field Sort Clause.
Ibexa\Contracts\Core\FieldType\Indexable as an extra service and register this Service using the
ibexa.field_type.indexable tag. Example from
1 2 3 4
alias should be the same as Field Type ID.
Search Field values¶
The search Field values returned by the
getIndexData method are simple value objects consisting of the following properties:
||The name of the field|
||The value of the field|
Search Field Types¶
There are many available search Field Types which are handled by search backend configuration. When using them, there is no need to adapt, for example, the Solr configuration in any way. You can always use custom Field Types, but these might require re-configuration of the search backend. For Solr this would mean adapting the
The default available search Field Types that can be found in the
Ibexa\Contracts\Core\Search\FieldType namespace are:
||Custom Field, for custom search data types. Will probably require additional configuration in the search backend.|
||Date field. Can be used for date range queries.|
||Field for floating point numbers.|
||Represents full text searchable value of the Field which can be indexed by the legacy search engine. Some full text Fields are stored as an array of strings.|
||Field used for Geo Location.|
||Field used for IDs. Basically acts like the string Field, but will not be queried by fulltext searches|
||Field for integer numbers.|
||Multiple boolean values.|
||Multiple IDs values.|
||Multiple integer numbers.|
||Multiple string values.|
||Field for price values. Currency conversion might be applied by the search backends. Might require careful configuration.|
||Standard string values. Will also be queries by full text searches.|
||Standard text values. Will be queried by full text searches. Configured text normalizations in the search backend apply.|
As mentioned before, if you use the standard type definitions, there is no need to configure the search backend in any way.
The Field definitions are handled using
dynamicField definitions in Solr, for example.
If you want to configure the handling of your Field, you can always add a special Field definition to the Solr
schema.xml. For Fields, the Field Type names used by the Solr search backend look like this:
You can define custom
dynamicField definitions to match, for example, on your custom
You could also define a custom Field definition for certain Fields, like for the name Field in an article:
If you want to learn more about the Solr implementation and detailed information about configuring it, check out the Solr Search Bundle.