Beispiel #1
0
 /**
  * get elasticsearch field mapping
  *
  * @param $attribute Mage_Eav_Model_Entity_Attribute_Abstract
  * @param $fieldType
  * @return array
  */
 protected function _getFieldMapping(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $fieldType, $fieldName)
 {
     switch ($fieldType) {
         case 'date':
             $mapping['type'] = 'date';
             $mapping['format'] = 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd';
             break;
         case 'string':
             //@todo add backend flags for analyzers and so on
             if (1 == $attribute->getisSearchable() || 1 == $attribute->getisVisibleInAdvancedSearch()) {
                 $mapping = array('type' => 'multi_field', 'fields' => array($fieldName => array("store" => 'no', 'type' => 'string', 'boost' => $attribute->getSearchWeight()), 'untouched' => array('type' => 'string', 'index' => 'not_analyzed')));
                 //for now we implementing all analyzer
                 //@todo make multiselect in backend to make analyser selectable
                 $settings = $this->_getIndexSettings();
                 foreach (array_keys($settings['analysis']['analyzer']) as $analyzer) {
                     $mapping['fields'][$analyzer] = array('type' => 'string', 'analyzer' => $analyzer, 'boost' => $attribute->getSearchWeight());
                 }
             } else {
                 $mapping = array('type' => 'string', 'index' => 'not_analyzed');
             }
             break;
         default:
             $mapping = array('type' => $fieldType);
             break;
     }
     return $mapping;
 }