MediaWiki REL1_35
SearchIndexFieldDefinition.php
Go to the documentation of this file.
1<?php
2
13
19 protected $name;
20
26 protected $type;
27
33 protected $flags = 0;
34
39 protected $subfields = [];
40
45
50 public function __construct( $name, $type ) {
51 $this->name = $name;
52 $this->type = $type;
53 }
54
59 public function getName() {
60 return $this->name;
61 }
62
67 public function getIndexType() {
68 return $this->type;
69 }
70
79 public function setFlag( $flag, $unset = false ) {
80 if ( $unset ) {
81 $this->flags &= ~$flag;
82 } else {
83 $this->flags |= $flag;
84 }
85 return $this;
86 }
87
95 public function checkFlag( $flag ) {
96 return $this->flags & $flag;
97 }
98
106 public function merge( SearchIndexField $that ) {
107 if ( !empty( $this->mergeCallback ) ) {
108 return call_user_func( $this->mergeCallback, $this, $that );
109 }
110 // TODO: which definitions may be compatible?
111 if ( ( $that instanceof self ) && $this->type === $that->type &&
112 $this->flags === $that->flags && $this->type !== self::INDEX_TYPE_NESTED
113 ) {
114 return $that;
115 }
116 return false;
117 }
118
123 public function getSubfields() {
124 return $this->subfields;
125 }
126
132 public function setSubfields( array $subfields ) {
133 $this->subfields = $subfields;
134 return $this;
135 }
136
142 abstract public function getMapping( SearchEngine $engine );
143
148 public function setMergeCallback( $callback ) {
149 $this->mergeCallback = $callback;
150 }
151
155 public function getEngineHints( SearchEngine $engine ) {
156 return [];
157 }
158}
Contain a class for special pages Stable to extend.
Basic infrastructure of the field definition.
SearchIndexFieldDefinition[] $subfields
Subfields.
getEngineHints(SearchEngine $engine)
A list of search engine hints for this field.Hints are usually specific to a search engine implementa...
setMergeCallback( $callback)
Set field-specific merge strategy.
getMapping(SearchEngine $engine)
merge(SearchIndexField $that)
Merge two field definitions if possible.
setFlag( $flag, $unset=false)
Set global flag for this field.
setSubfields(array $subfields)
Set subfields.
string $type
Type of the field, one of the constants above.
int $flags
Bit flags for the field.
checkFlag( $flag)
Check if flag is set.
Definition of a mapping for the search index field.