123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- class SearchApiSolrField {
-
- public static $schemaLabels = array(
- 'I' => 'Indexed',
- 'T' => 'Tokenized',
- 'S' => 'Stored',
- 'M' => 'Multivalued',
- 'V' => 'TermVector Stored',
- 'o' => 'Store Offset With TermVector',
- 'p' => 'Store Position With TermVector',
- 'O' => 'Omit Norms',
- 'L' => 'Lazy',
- 'B' => 'Binary',
- 'C' => 'Compressed',
- 'f' => 'Sort Missing First',
- 'l' => 'Sort Missing Last',
- );
-
- protected $field;
-
- protected $schema;
-
- public function __construct($field) {
- $this->field = $field;
- }
-
- public function getType() {
- return $this->field->type;
- }
-
- public function getSchema() {
- if (!isset($this->schema)) {
- foreach (str_split(str_replace('-', '', $this->field->schema)) as $key) {
- $this->schema[$key] = isset(self::$schemaLabels[$key]) ? self::$schemaLabels[$key] : $key;
- }
- }
- return $this->schema;
- }
-
- public function getDynamicBase() {
- return isset($this->field->dynamicBase) ? $this->field->dynamicBase : NULL;
- }
-
- public function isPossibleKey() {
- return !$this->getDynamicBase()
- && !in_array($this->getType(), array('boolean', 'date', 'text'))
- && $this->isStored()
- && !$this->isMultivalued();
- }
-
- public function isSortable() {
- return $this->isIndexed()
- && !$this->isMultivalued()
- && !$this->isTokenized();
- }
-
- public function isIndexed() {
- $this->getSchema();
- return isset($this->schema['I']);
- }
- public function isTokenized() {
- $this->getSchema();
- return isset($this->schema['T']);
- }
- public function isStored() {
- $this->getSchema();
- return isset($this->schema['S']);
- }
- public function isMultivalued() {
- $this->getSchema();
- return isset($this->schema['M']);
- }
- public function isTermVectorStored() {
- $this->getSchema();
- return isset($this->schema['V']);
- }
- public function isStoreOffsetWithTermVector() {
- $this->getSchema();
- return isset($this->schema['o']);
- }
- public function isStorePositionWithTermVector() {
- $this->getSchema();
- return isset($this->schema['p']);
- }
- public function isOmitNorms() {
- $this->getSchema();
- return isset($this->schema['O']);
- }
- public function isLazy() {
- $this->getSchema();
- return isset($this->schema['L']);
- }
- public function isBinary() {
- $this->getSchema();
- return isset($this->schema['B']);
- }
- public function isCompressed() {
- $this->getSchema();
- return isset($this->schema['C']);
- }
- public function isSortMissingFirst() {
- $this->getSchema();
- return isset($this->schema['f']);
- }
- public function isSortMissingLast() {
- $this->getSchema();
- return isset($this->schema['l']);
- }
- }
|