DESCRIPTION

The module is a plugin for App::ZofCMS that incorporates (partial) Search::Indexer functionality in a form of ZofCMS plugin. In other words, plugin allows one to create a search index from a bunch of data and later on perform search on that index. See docs for Search::Indexer for more details.

Mandatory. The plug_search_indexer first-level key can be specified in either ZofCMS Template or Main Config File (or both). Its value can be either a subref or a hashref; if the value is a subref it will be evaluated and it must return a hashref (or undef/empty list). This hashref will be treated as if you directly assigned it to plug_search_indexer key. The @_ of that subref will contain the following $t, $q, $conf where $t is ZofCMS Template hashref, $q is a hashref of query parameters and $conf is App::ZofCMS::Config object. Possible keys/values of plug_search_indexer hashref are as follows:

obj_args

obj_args => [],

Optional. Takes an arrayref as a value, this arrayref will be directly dereferenced into Search::Indexer's constructor (new() method). The writeMode argument will be set by the plugin to a true value if add or remove keys (see below) are set. The dir argument will be derived from plugin's dir key. The arrayref will be dereferenced after the dir and writeMode arguments, thus you can use obj_args to override them. See documentation for Search::Indexer for possible values that you can set in obj_args. Defaults to:[] (empty arrayref).

cell

key

key => 'search_indexer',

Optional. Specifies the name of the key inside cell first-level key into which to put search results (when search is performed). See cell argument below. Basically, if cell is set to d and key is set to search_indexer then search results will be stored in $t->{d}{search_indexer} where $t is ZofCMS Template hashref. Defaults to:search_indexer

exact_match

exact_match => 0,

Optional. Takes either true or false values. Will be given as second parameter to Search::Indexer's search() method; thus if it is set to true all the search words without prefix will have + added to them. Defaults to:0

add

add => {
id1 => 'text to index',
id2 => 'other text to index',
},

Optional. When specified, instructs the plugin to add stuff into index. Takes a hashref as a value where keys are IDs and values are text to index under those IDs.

remove

Optional. Takes either a hashref or an arrayref as a value. Elements of the arrayref would be IDs of records to remove from the index. You'd use the hashref form when positions argument in obj_args arrayref would be set to a false value (by default it's true); when that's the case, the keys of hashref would be IDs and values would be corresponding texts. See remove() method and positions argument to new() method in Search::Indexer

search

search => 'foo bar baz',

Optional. Takes a string as a value. This string will be given to Search::Indexer's search() method as a first argument, i.e. the text for which to search. The return value will be the same as return value of Search::Indexer's search() method and it will be assigned to $t->{ <cell> }{ <key> } where $t is ZofCMS Template hashref and <cell> and <key> are cell and key plugin's arguments respectively.