Abstract representation of a search source.

package XenForo_Search

 Methods

Deletes the specified records from the index.

deleteFromIndex(string $contentType, array $contentIds) 

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) 

An error will prevent the search from going through.

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))

Executes a search for content by a specific user.

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

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

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

Gets the general order clauses for a search.

getGeneralOrderClause(string $order) : array

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)

Inserts (or prepares to insert) a new record into the search 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.

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

Process search constraints.

processConstraints(array $constraints, \XenForo_Search_DataHandler_Abstract $typeHandler) : array

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

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

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

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) 

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

Parameters

$rebuild

boolean

Sets the containing searcher object.

setSearcher(\XenForo_Search_Searcher $searcher) 

This will be used for things like error tracking.

Parameters

Determines if this source handler supports relevance searching.

supportsRelevance() : boolean

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

Returns

boolean

Updates specific fields in an already existing index record.

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

Metadata cannot be updated this way.

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) 

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

Parameters

$message

\XenForo_Phrasestring

Warning message

$field

string

Field warning applies to

_getDb()

_getDb() : \Zend_Db_Adapter_Abstract

Returns

\Zend_Db_Adapter_Abstract

 Properties

 

$_db

$_db : \Zend_Db_Adapter_Abstract

 

Determines if this process is doing a bulk rebuild.

$_isRebuild : boolean

 

$_searcher

$_searcher : \XenForo_Search_Searcher | null