4 * Basic infrastructure of the field definition.
5 * Specific engines will need to override it at least for getMapping,
6 * but can reuse other parts.
9 abstract class SearchIndexFieldDefinition
implements SearchIndexField
{
17 * Type of the field, one of the constants above
23 * Bit flags for the field.
30 * @var SearchIndexFieldDefinition[]
32 protected $subfields = [];
35 * SearchIndexFieldDefinition constructor.
36 * @param string $name Field name
37 * @param int $type Index type
39 public function __construct( $name, $type ) {
48 public function getName() {
56 public function getIndexType() {
61 * Set global flag for this field.
63 * @param int $flag Bit flag to set/unset
64 * @param bool $unset True if flag should be unset, false by default
67 public function setFlag( $flag, $unset = false ) {
69 $this->flags
&= ~
$flag;
71 $this->flags |
= $flag;
77 * Check if flag is set.
79 * @return int 0 if unset, !=0 if set
81 public function checkFlag( $flag ) {
82 return $this->flags
& $flag;
86 * Merge two field definitions if possible.
88 * @param SearchIndexField $that
89 * @return SearchIndexField|false New definition or false if not mergeable.
91 public function merge( SearchIndexField
$that ) {
92 // TODO: which definitions may be compatible?
93 if ( ( $that instanceof self
) && $this->type
=== $that->type
&&
94 $this->flags
=== $that->flags
&& $this->type
!== self
::INDEX_TYPE_NESTED
103 * @return SearchIndexFieldDefinition[]
105 public function getSubfields() {
106 return $this->subfields
;
111 * @param SearchIndexFieldDefinition[] $subfields
114 public function setSubfields( array $subfields ) {
115 $this->subfields
= $subfields;