\ZendSearchLuceneSearchable
Decorates a DataObject, giving it the ability to be indexed and searched by Zend_Search_Lucene.
To define custom columns, you should this line into your site _config.php:
<code>
ZendSearchLuceneSearchable::enable(array());
</code>
This sets up things without defining columns for any classes.
After this, you can define non-default columns to index for each object by using:
<code>
Object::add_extension(
'SiteTree',
"ZendSearchLuceneSearchable('Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords')"
);
</code>
See the docs for the __construct function for advanced config options.
- Author: Darren Inwood <darren.inwood@chrometoaster.com>
Synopsis
class ZendSearchLuceneSearchable
extends DataExtension
{
- // members
- public static integer $pageLength = 10;
- public static integer $alwaysShowPages = 3;
- public static integer $maxShowPages = 8;
- public static string $encoding = 'utf-8';
- public static $cacheDirectory = TEMP_FOLDER;
- public static boolean $reindexOnDevBuild = true;
- protected static array $extraSearchFields = ;
- protected static array $defaultColumns = ;
- protected static array $unstored_fields = ;
- protected static array $unindexed_fields = ;
- protected static array $keyword_fields = ;
- protected $fieldConfig = NULL;
- protected $_fieldConfig = NULL;
- protected $classConfig = NULL;
- protected $_classConfig = NULL;
- // methods
- public void __construct()
- private void setLuceneFieldConfig()
- public void getLuceneFieldConfig()
- private void setLuceneClassConfig()
- public void getLuceneClassConfig()
- public static void enable()
- public void onAfterWrite()
- public void onAfterDelete()
- public Array getSearchedVars()
- public Array getSearchFields()
- public Array getExtraSearchFields()
- public void requireDefaultRecords()
Hierarchy
Extends
- DataExtension
Members
protected
-
$_classConfig
The raw string used to configure the object. We have to store it and parse it on first use at runtime, because the owner of the decorator isn't set in the constructor. -
$_fieldConfig
The raw string used to configure the object's fields. We have to store it and parse it on first use at runtime, because the owner of the decorator isn't set in the constructor. -
$classConfig
The config options for this DataObject class. This is not public, and should be set by configuring the class via the Object::add_extension argument. -
$defaultColumns
Default fields to index for each Searchable decorated class. This isn't public - it's just a convenience thing, for those people who just want to get up and running with indexing SiteTree and File with minimum configuration. -
$extraSearchFields
Fields which are also indexed in addition to content fields. -
$fieldConfig
The fields which can be searched for each DataObject class, and indexing info for each field. This is not public, and should be set by configuring the class via the Object::add_extension argument. -
$keyword_fields
Fields which should be indexed as 'keyword' by default. -
$unindexed_fields
Fields which should be indexed as 'unindexed' by default. -
$unstored_fields
Fields which should be indexed as 'unstored' by default.
public
-
$alwaysShowPages
Always show this many pages in pagination (can be zero) -
$cacheDirectory
Full filesystem path to the directory where the index files should live -
$encoding
Encoding in which indexes are created and searches made. -
$maxShowPages
Maximum number of pages shown in pagination (ellipsis are used to indicate more pages) -
$pageLength
Number of results per pagination page -
$reindexOnDevBuild
Boolean indicating whether we should rebuild the index whenever a dev/build is run.
Methods
private
- setLuceneClassConfig() — Set up search configuration for the class.
- setLuceneFieldConfig() — Set up the config for each instantiated object for this class.
public
- __construct() — Called by the system when initialising each instance of the decorated class. The argument comes from the Object::add_extension call in the project's _config.php file.
- enable() — Enable the default configuration of Zend Search Lucene searching on the given data classes.
- getExtraSearchFields() — Get an array of the class' extra search fieldnames that are indexed but not searched.
- getLuceneClassConfig() — Returns the class config array.
- getLuceneFieldConfig() — Returns the field config array for a given field. Throws a user_error if the field doesn't exist in the config.
- getSearchFields() — Get an array of the class' searched fieldnames from other classes.
- getSearchedVars() — Return an array of search field names.
- onAfterDelete() — Removes the object from the search index after it has been deleted.
- onAfterWrite() — Indexes the object after it has been written to the database.
- requireDefaultRecords() — Rebuilds the search index whenever a dev/build is run.