Download the PHP package dnadesign/silverstripe-elemental-textcontentforsearch without Composer
On this page you can find all versions of the php package dnadesign/silverstripe-elemental-textcontentforsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dnadesign/silverstripe-elemental-textcontentforsearch
More information about dnadesign/silverstripe-elemental-textcontentforsearch
Files in dnadesign/silverstripe-elemental-textcontentforsearch
Package silverstripe-elemental-textcontentforsearch
Short Description A set of helper methods to facilitate indexing elemental pages text content
License BSD-3-Clause
Informations about the package silverstripe-elemental-textcontentforsearch
silverstripe-elemental-textcontentforsearch
A set of helper methods to facilitate searching elemental pages
Requirements
- Silverstripe CMS ^5
- Silverstripe Elemental ^5
Installation
For Silverstripe 4, use version 1.0.0
The following YAML config will enable elements on every Page
object,
replacing the standard Content
rich text field and add access to the getTextContentForSearch
method
mysite/_config/elements.yml
Usage
SolrIndex
We recommend you use the TextContentForSearch
instead of the ElementForSearch
method in your index.
This avoids rendering the entire elemental area, which would include images and complex elements, which consumes a lot of resources
during render and don't end up in the index anyway.
Configuration
By default, the process will extract any Varchar
, Text
and HTMLText
field from the elements.
If you require any other type of fields to be considered for indexing, you ca update the config as follow:
You can exclude fields per element. By default, the Style
and ExtraClass
fields are excluded as they wouldn't bring any value
to the search. To exclude a field, you can either set the config on the class or in the yaml:
or
In reverse, you can add a field in the same way.
or
In addition, you can implement a updateTextFieldsForSearch
method on any element or extension to update the list of fields to include in search.
Some elements may have complex relationships that are not explored by the default process.
You can implement addTextContentForSearch
to concatenate extra content to the final string.
Ultimately, you can manipulate the final string to be return by implementing updateTextContentForSearch
method.
By default, every element is considered for indexing. If you wish to exclude an element from the search, you can use the config as follow:
or
Debugging
As it is difficult to see what is being included in the solr index, the module exposes a read only text field with the
content generated by the getTextContentForSearch
method.
You can hide this field by amending the config:
Notes:
- The introspective process will explore any
VirtualElement
and extract the parent element text fields
To do:
- Add an option to store the search string in the DB on save?