Handler for searching with MySQL's full text search.

package XenForo_Search

 Methods

__construct()

__construct() 

Deletes one or more record from the index.

deleteFromIndex(string $contentType, array $contentIds) 
see \XenForo_Search_SourceHandler_Abstract::deleteFromIndex()

Parameters

$contentType

string

$contentIds

array

List of content IDs (of $contentType to delete)

Triggers an error with the searcher object.

error(\XenForo_Phrase | string $message, string $field) 
Inherited

An error will prevent the search from going through.

inherited_from \XenForo_Search_SourceHandler_Abstract::error()

Parameters

$message

\XenForo_Phrasestring

Error message

$field

string

Field error applies to

Executes a search against the full text index.

executeSearch(string $searchQuery, boolean $titleOnly, array $processedConstraints, array $orderParts, string $groupByDiscussionType, integer $maxResults, \XenForo_Search_DataHandler_Abstract $typeHandler) : array

Parameters

$searchQuery

string

Text to search for

$titleOnly

boolean

If true, only searches text in titles

$processedConstraints

array

Structured constraints

$orderParts

array

Structured ordered by parts

$groupByDiscussionType

string

If grouping, content type of grouped results

$maxResults

integer

$typeHandler

\XenForo_Search_DataHandler_Abstract

Type-specific handler, for joins

Returns

arraySearch results ([] => array(content type, id))

Searches for content by the specified user ID.

executeSearchByUserId(integer $userId, integer $maxDate, integer $maxResults) : array

Currently this includes no constraints, but down the line it may support non-query constraints.

see \XenForo_Search_SourceHandler_Abstract::executeSearchByUserId()

Parameters

$userId

integer

$maxDate

integer

If >0, only messages older than this should be found

$maxResults

integer

Returns

arraySearch results ([] => array(content type, id))

When rebuilding, it might be advantageous to bulk update records.

finalizeRebuildSet() 

This function must be called to ensure that all records are updated together.

Gets the default source handler.

getDefaultSourceHandler() : \XenForo_Search_SourceHandler_Abstract
InheritedStatic
inherited_from \XenForo_Search_SourceHandler_Abstract::getDefaultSourceHandler()

Returns

Gets the general order clauses for a search.

getGeneralOrderClause(string $order) : array
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::getGeneralOrderClause()

Parameters

$order

string

User-requested order

Returns

arrayStructured order clause, array of arrays. Child array keys: 0 = table alias, 1 = field, 2 = dir (asc/desc)

Gets the string form of a piece of metadata.

getMetadataKey(string $keyName, string | array $value) : string | array

Parameters

$keyName

string

Type of metadata

$value

stringarray

Metadata value; if an array, gets metadata for each value

Returns

stringarrayString if $value was a string, array if $value was an array

Inserts or replaces into the index.

insertIntoIndex(string $contentType, integer $contentId, string $title, string $message, integer $itemDate, integer $userId, integer $discussionId, array $metadata) 

This must also update (replace) an existing record, if the (type, id) pair already exists.

see \XenForo_Search_SourceHandler_Abstract::insertIntoIndex()

Parameters

$contentType

string

$contentId

integer

$title

string

$message

string

$itemDate

integer

Time stamp for the content (this will be used in date limits and sorts)

$userId

integer

User that created the content

$discussionId

integer

ID of discussion or other grouping container

$metadata

array

Arbitrary list of other metadata that should be indexed if possible

Parses a tokenized query into the final query to give to MySQL.

parseTokenizedQuery(array $query, array $processedConstraints) : string

Metadata will also be searched in the query.

Parameters

$query

array

Tokenized query

$processedConstraints

array

Constraints, in source-agnostic format

Returns

stringQuery ready for MySQL

Process search constraints.

processConstraints(array $constraints, \XenForo_Search_DataHandler_Abstract $typeHandler) : array
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::processConstraints()

Parameters

$constraints

array

List of constraints: [constraint name] => limit (may be scalar or array)

Returns

arrayProcessed constraints. Names as keys, value is array with possible keys: * metadata - metadata value; keys: 0 = name of metadata, 1 = scalar/array allowed value(s) for metadata * query - constraint to limit via query; keys: 0 = table alias, 1 = field, 2 = operator, 3 = scalar/array allowed value(s). Multiple for "=" operator only. Note that the metadata and query keys are assumed to be equivalent. Engines need only use one (depending on engine details).

Performs a general search.

searchGeneral(string $searchQuery, array $constraints, string $order, integer $maxResults) : array
Inherited

This will usually be across all types of content, but could be limited but only using standard constraints.

inherited_from \XenForo_Search_SourceHandler_Abstract::searchGeneral()

Parameters

$searchQuery

string

Text to search for

$constraints

array

Constraints to apply; handled by source handlers

$order

string

Ordering; handled by source handlers

$maxResults

integer

Maximum number of results to return

Returns

arraySearch results: [] => array(content_type => x, content_id => y)

Performs a type specific search.

searchType(\XenForo_Search_DataHandler_Abstract $typeHandler, string $searchQuery, array $constraints, string $order, boolean $groupByDiscussion, integer $maxResults) : array
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::searchType()

Parameters

$typeHandler

\XenForo_Search_DataHandler_Abstract

Data handler for the type of search

$searchQuery

string

Text to search for

$constraints

array

Constraints to apply; handled by source handlers

$order

string

Ordering; handled by source handlers

$groupByDiscussion

boolean

If true, fold/group the results by the discussion_id value

$maxResults

integer

Maximum number of results to return

Returns

arraySearch results: [] => array(content_type => x, content_id => y)

Sets whether this is a bulk rebuild.

setIsRebuild(boolean $rebuild) 
Inherited

If true, behavior may be modified to be less asynchronous.

inherited_from \XenForo_Search_SourceHandler_Abstract::setIsRebuild()

Parameters

$rebuild

boolean

Sets the containing searcher object.

setSearcher(\XenForo_Search_Searcher $searcher) 
Inherited

This will be used for things like error tracking.

inherited_from \XenForo_Search_SourceHandler_Abstract::setSearcher()

Parameters

$searcher

\XenForo_Search_Searchernull

Split words by the delimiters used by MySQL.

splitWords(string $words) : array

Parameters

$words

string

Returns

array

Determines if this source supports relevance sorting.

supportsRelevance() : \boolean;

If false, it will not be made available as a sorting option.

Returns

\boolean;

Tokenizes a search query into parts.

tokenizeQuery(string $query) : array

Parameters

$query

string

Returns

arrayTokenized query, [] => array(0 => modifier (empty, +, -, |), 1 => term). Term will include ".." if given.

Updates a record in the index.

updateIndex(string $contentType, integer $contentId, array $fieldUpdates) 

Metadata cannot be updated this way.

see \XenForo_Search_SourceHandler_Abstract::updateIndex()

Parameters

$contentType

string

$contentId

integer

$fieldUpdates

array

Key-value pairs to change

Triggers a warning with the searcher object.

warning(\XenForo_Phrase | string $message, string $field) 
Inherited

This will be shown to the user on the search results page.

inherited_from \XenForo_Search_SourceHandler_Abstract::warning()

Parameters

$message

\XenForo_Phrasestring

Warning message

$field

string

Field warning applies to

_getDb()

_getDb() : \Zend_Db_Adapter_Abstract
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::_getDb()

Returns

\Zend_Db_Adapter_Abstract

Runs the actual query to replace/update the index.

_pushToIndex(string | array $record) 

Parameters

$record

stringarray

A record (SQL) or array of SQL

 Properties

 

$stopWords 
 

$_bulkInsertLength 
 

$_bulkInserts 
 

$_db : \Zend_Db_Adapter_Abstract
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::$$_db
 

$_isRebuild : boolean
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::$$_isRebuild
 

$_minWordLength : integer

Used for error/warning detection.

 

$_searcher : \XenForo_Search_Searcher | null
Inherited
inherited_from \XenForo_Search_SourceHandler_Abstract::$$_searcher

 Constants

 

SPLIT_CHAR_RANGES

SPLIT_CHAR_RANGES