You are here

class SarniaSearchApiSolrField in Sarnia 7

Extend the logic around Solr field schema information.

Hierarchy

Expanded class hierarchy of SarniaSearchApiSolrField

File

./solr_field.inc, line 6

View source
class SarniaSearchApiSolrField extends SearchApiSolrField {

  /**
   * @var string
   *   The name of the field.
   */
  protected $name;

  /**
   * Constructor.
   *
   * @param stdClass $field
   *   A field object from Solr's "Luke" servlet.
   */
  public function __construct(SearchApiSolrField $field, $name = NULL) {
    $this->field = $field->field;
    $this->name = $name;
  }

  /**
   * Get the name of the Solr field.
   *
   * @return string
   *   The name of the Solr field.
   */
  public function getName() {
    return $this->name;
  }

  /**
   * Determine whether this field may be suitable for use as a key field.
   *
   * Unfortunately, it seems like the best way to find an actual uniqueKey field
   * according to Solr is to examine the Solr core's schema.xml.
   *
   * @return boolean
   *   Whether the field is suitable for use as a key.
   */
  public function isPossibleKey() {
    return !$this
      ->getDynamicBase() && $this
      ->isStored() && !$this
      ->isMultivalued();
  }

  /**
   * Determine whether a field is suitable for sorting.
   *
   * In order for a field to yield useful sorted results in Solr, it must be
   * indexed and not multivalued. If a sort field is tokenized, the tokenization
   * must yield only one token; multiple tokens can result in unpredictable sort
   * ordering. Unfortunately, there's no way to check whether a particular field
   * contains values with multiple tokens.
   *
   * @return boolean
   *   Whether the field might be suitable for sorting.
   */
  public function isSortable() {
    return $this
      ->isIndexed() && !$this
      ->isMultivalued();
  }

  /**
   * Determine whether a field is suitable for fulltext search.
   *
   * Some fields are tokenized for sort and contain a single, all lowercase
   * value. These fields are not suitable for fulltext search, but there is no
   * general way to tell them apart from fields that are tokenized into multiple
   * terms.
   *
   * @see SearchApiSolrField::isSortable()
   *
   * @return boolean
   *   Whether the field might be suitable for fulltext search.
   */
  public function isFulltextSearchable() {
    return $this
      ->isIndexed() && $this
      ->isTokenized();
  }

  /**
   * Determine whether a field is suitable for filtering (non-fulltext, case sensitive search).
   *
   * When searching on this type of field, only full, exact values will match.
   *
   * @return boolean
   *   Whether the field might be suitable for filtering.
   */
  public function isFilterable() {
    return $this
      ->isIndexed() && !$this
      ->isTokenized();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SarniaSearchApiSolrField::$name protected property The name of the field.
SarniaSearchApiSolrField::getName public function Get the name of the Solr field.
SarniaSearchApiSolrField::isFilterable public function Determine whether a field is suitable for filtering (non-fulltext, case sensitive search).
SarniaSearchApiSolrField::isFulltextSearchable public function Determine whether a field is suitable for fulltext search.
SarniaSearchApiSolrField::isPossibleKey public function Determine whether this field may be suitable for use as a key field. Overrides SearchApiSolrField::isPossibleKey
SarniaSearchApiSolrField::isSortable public function Determine whether a field is suitable for sorting. Overrides SearchApiSolrField::isSortable
SarniaSearchApiSolrField::__construct public function Constructor. Overrides SearchApiSolrField::__construct
SearchApiSolrField::$field protected property The original field object.
SearchApiSolrField::$schema protected property An array of schema properties for this field. This will be a subset of the SearchApiSolrField::schemaLabels array.
SearchApiSolrField::$schemaLabels public static property Human-readable labels for Solr schema properties.
SearchApiSolrField::getDynamicBase public function Gets the "dynamic base" of this field.
SearchApiSolrField::getRaw public function Gets the raw information of the field.
SearchApiSolrField::getSchema public function Gets an array of field properties.
SearchApiSolrField::getType public function Gets the type of the Solr field, according to the Solr schema.
SearchApiSolrField::isBinary public function Determines whether this field is binary.
SearchApiSolrField::isCompressed public function Determines whether this field is compressed.
SearchApiSolrField::isIndexed public function Determines whether this field is indexed.
SearchApiSolrField::isLazy public function Determines whether this field is lazy-loaded.
SearchApiSolrField::isMultivalued public function Determines whether this field is multi-valued.
SearchApiSolrField::isOmitNorms public function Determines whether this field omits norms when indexing.
SearchApiSolrField::isSortMissingFirst public function Determines whether this field sorts missing entries first.
SearchApiSolrField::isSortMissingLast public function Determines whether this field sorts missing entries last.
SearchApiSolrField::isStored public function Determines whether this field is stored.
SearchApiSolrField::isStoreOffsetWithTermVector public function Determines whether this field has the "termOffsets" option set.
SearchApiSolrField::isStorePositionWithTermVector public function Determines whether this field has the "termPositions" option set.
SearchApiSolrField::isTermVectorStored public function Determines whether this field has stored term vectors.
SearchApiSolrField::isTokenized public function Determines whether this field is tokenized.