Example #1
0
 /**
  * @param Field $field
  * @param \stdClass $rootObject
  * @param string $path
  * @return array
  */
 protected function mapString(Field $field, \stdClass $rootObject, $path = null)
 {
     switch ($field->getFormat()->getValue()) {
         case Format::DATE:
         case Format::DATE_TIME:
             return $this->types['date-time'];
             /**
              * String fields with these formats should use "pbj_keyword_analyzer" (or something similar)
              * so searches on these fields are not case sensitive.
              *
              * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html
              * @link http://stackoverflow.com/questions/15079064/how-to-setup-a-tokenizer-in-elasticsearch
              */
         /**
          * String fields with these formats should use "pbj_keyword_analyzer" (or something similar)
          * so searches on these fields are not case sensitive.
          *
          * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html
          * @link http://stackoverflow.com/questions/15079064/how-to-setup-a-tokenizer-in-elasticsearch
          */
         case Format::SLUG:
         case Format::EMAIL:
         case Format::HOSTNAME:
         case Format::IPV6:
         case Format::UUID:
         case Format::URI:
         case Format::HASHTAG:
             return ['type' => 'string', 'analyzer' => 'pbj_keyword_analyzer', 'include_in_all' => false];
         case Format::IPV4:
             return ['type' => 'ip', 'include_in_all' => false];
         case Format::URL:
             return ['type' => 'string', 'index' => 'no', 'include_in_all' => false];
         default:
             if ($field->getPattern()) {
                 return ['type' => 'string', 'analyzer' => 'pbj_keyword_analyzer', 'include_in_all' => false];
             }
             return $this->applyAnalyzer(['type' => 'string'], $field, $rootObject, $path);
     }
 }