MediaWiki master
MediaWiki\Search\SearchIndexFieldDefinition Class Reference

Basic infrastructure of the field definition. More...

Inherits MediaWiki\Search\SearchIndexField.

Inherited by MediaWiki\Search\DummySearchIndexFieldDefinition.

Collaboration diagram for MediaWiki\Search\SearchIndexFieldDefinition:

Public Member Functions

 __construct ( $name, $type)
 
 checkFlag ( $flag)
 Check if flag is set.
 
 getEngineHints (SearchEngine $engine)
 A list of search engine hints for this field.Hints are usually specific to a search engine implementation and allow to fine control how the search engine will handle this particular field.For example some search engine permits some optimizations at index time by ignoring an update if the updated value does not change by more than X% on a numeric value.
Parameters
SearchEngine$engine
Returns
array an array of hints generally indexed by hint name. The type of values is search engine specific
Since
1.30

 
 getIndexType ()
 
 getMapping (SearchEngine $engine)
 
 getName ()
 Get field name.
 
 getSubfields ()
 
 merge (SearchIndexField $that)
 Merge two field definitions if possible.
 
 setFlag ( $flag, $unset=false)
 Set global flag for this field.
 
 setMergeCallback ( $callback)
 Set field-specific merge strategy.
 
 setSubfields (array $subfields)
 

Protected Attributes

int $flags = 0
 Bit flags for the field.
 
string $name
 Name of the field.
 
SearchIndexFieldDefinition[] $subfields = []
 Subfields.
 
string $type
 Type of the field, one of the constants above.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Search\SearchIndexField
const FLAG_CASEFOLD = 1
 Generic field flags.
 
const FLAG_NO_HIGHLIGHT = 4
 This field does not need highlight handling.
 
const FLAG_NO_INDEX = 8
 Do not index this field, just store it.
 
const FLAG_SCORING = 2
 This field contains secondary information, which is already present in other fields, but can be used for scoring.
 
const INDEX_TYPE_BOOL = 'bool'
 
const INDEX_TYPE_DATETIME = 'datetime'
 
const INDEX_TYPE_INTEGER = 'integer'
 
const INDEX_TYPE_KEYWORD = 'keyword'
 KEYWORD fields are indexed without any processing, so are appropriate for e.g.
 
const INDEX_TYPE_NESTED = 'nested'
 
const INDEX_TYPE_NUMBER = 'number'
 
const INDEX_TYPE_SHORT_TEXT = 'short_text'
 SHORT_TEXT is meant to be used with short text made of mostly ascii technical information.
 
const INDEX_TYPE_TEXT = 'text'
 TEXT fields are suitable for natural language and may be subject to analysis such as stemming.
 

Detailed Description

Basic infrastructure of the field definition.

Specific engines should extend this class and at least, override the getMapping method, but can reuse other parts.

Stability: stable
to extend
Since
1.28

Definition at line 14 of file SearchIndexFieldDefinition.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Search\SearchIndexFieldDefinition::__construct ( $name,
$type )
Parameters
string$nameField name
string$typeIndex type

Definition at line 52 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexFieldDefinition\$name, and MediaWiki\Search\SearchIndexFieldDefinition\$type.

Member Function Documentation

◆ checkFlag()

MediaWiki\Search\SearchIndexFieldDefinition::checkFlag ( $flag)

Check if flag is set.

Stability: stable
to override
Parameters
int$flag
Returns
int 0 if unset, !=0 if set

Implements MediaWiki\Search\SearchIndexField.

Definition at line 96 of file SearchIndexFieldDefinition.php.

◆ getEngineHints()

MediaWiki\Search\SearchIndexFieldDefinition::getEngineHints ( SearchEngine $engine)

A list of search engine hints for this field.Hints are usually specific to a search engine implementation and allow to fine control how the search engine will handle this particular field.For example some search engine permits some optimizations at index time by ignoring an update if the updated value does not change by more than X% on a numeric value.

Parameters
SearchEngine$engine
Returns
array an array of hints generally indexed by hint name. The type of values is search engine specific
Since
1.30

Implements MediaWiki\Search\SearchIndexField.

Definition at line 154 of file SearchIndexFieldDefinition.php.

◆ getIndexType()

MediaWiki\Search\SearchIndexFieldDefinition::getIndexType ( )
Returns
string

Definition at line 68 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexFieldDefinition\$type.

◆ getMapping()

MediaWiki\Search\SearchIndexFieldDefinition::getMapping ( SearchEngine $engine)
abstract
Parameters
SearchEngine$engine
Returns
array

Implements MediaWiki\Search\SearchIndexField.

Reimplemented in MediaWiki\Search\DummySearchIndexFieldDefinition.

◆ getName()

MediaWiki\Search\SearchIndexFieldDefinition::getName ( )

Get field name.

Returns
string

Definition at line 61 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexFieldDefinition\$name.

◆ getSubfields()

MediaWiki\Search\SearchIndexFieldDefinition::getSubfields ( )
Returns
SearchIndexFieldDefinition[]

Definition at line 123 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexFieldDefinition\$subfields.

◆ merge()

MediaWiki\Search\SearchIndexFieldDefinition::merge ( SearchIndexField $that)

Merge two field definitions if possible.

Stability: stable
to override
Parameters
SearchIndexField$that
Returns
SearchIndexField|false New definition or false if not mergeable.

Implements MediaWiki\Search\SearchIndexField.

Definition at line 107 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexField\INDEX_TYPE_NESTED.

◆ setFlag()

MediaWiki\Search\SearchIndexFieldDefinition::setFlag ( $flag,
$unset = false )

Set global flag for this field.

Stability: stable
to override
Parameters
int$flagBit flag to set/unset
bool$unsetTrue if flag should be unset, false by default
Returns
$this

Implements MediaWiki\Search\SearchIndexField.

Definition at line 80 of file SearchIndexFieldDefinition.php.

◆ setMergeCallback()

MediaWiki\Search\SearchIndexFieldDefinition::setMergeCallback ( $callback)

Set field-specific merge strategy.

Parameters
callable$callback

Definition at line 147 of file SearchIndexFieldDefinition.php.

◆ setSubfields()

MediaWiki\Search\SearchIndexFieldDefinition::setSubfields ( array $subfields)
Parameters
SearchIndexFieldDefinition[]$subfields
Returns
$this

Definition at line 131 of file SearchIndexFieldDefinition.php.

References MediaWiki\Search\SearchIndexFieldDefinition\$subfields.

Member Data Documentation

◆ $flags

int MediaWiki\Search\SearchIndexFieldDefinition::$flags = 0
protected

Bit flags for the field.

Definition at line 35 of file SearchIndexFieldDefinition.php.

Referenced by MediaWiki\Search\DummySearchIndexFieldDefinition\getMapping().

◆ $name

string MediaWiki\Search\SearchIndexFieldDefinition::$name
protected

◆ $subfields

SearchIndexFieldDefinition [] MediaWiki\Search\SearchIndexFieldDefinition::$subfields = []
protected

◆ $type

string MediaWiki\Search\SearchIndexFieldDefinition::$type
protected

The documentation for this class was generated from the following file: