src/searchOld/elastic/Watch.php
protected function fillForModel($index, $model)
    {
        if (false === empty($model->propertiesIds) && false === empty($model->propertiesValues)) {
            //leave only not empty properties
            $workingProps = array_filter($model->propertiesValues, function ($e) {
                if (true === is_array($e)) {
                    foreach ($e as $val) {
                        return (count($val) > 0 && false === empty($val[0]));
                    }
                } else {
                    return false === empty($e);
                }
            });
            //collecting storages
            $storage = (new Query())
                ->from(PropertyStorage::tableName())
                ->select('id')
                ->indexBy('class_name')
                ->column();
            //selecting all applicable properties to work with
            $rawProps = (new Query())->from(Property::tableName())
                ->select(['id', 'key', 'storage_id', 'data_type'])
                ->where([
                    'id' => array_keys($workingProps),
                    'in_search' => 1
                ])
                ->all();
            $props = ArrayHelper::map($rawProps, 'id', 'key', 'storage_id');
            foreach ($storage as $className => $id) {
                if (false === isset($props[$id]) || true === empty($props[$id])) {
                    continue;
                }
                $indexData = self::prepareIndexData($className, $props[$id], $workingProps, $index, $model);
                if (false === empty($indexData)) {
                    $this->client->bulk($indexData);
                }
            }
        }
    }
protected function fillForModel($index, $model)
    {
        if (false === empty($model->propertiesIds) && false === empty($model->propertiesValues)) {
            //leave only not empty properties
            $workingProps = array_filter($model->propertiesValues, function ($e) {
                if (true === is_array($e)) {
                    foreach ($e as $val) {
                        return (count($val) > 0 && false === empty($val[0]));
                    }
                } else {
                    return false === empty($e);
                }
            });
            //collecting storages
            $storage = (new Query())
                ->from(PropertyStorage::tableName())
                ->select('id')
                ->indexBy('class_name')
                ->column();
            //selecting all applicable properties to work with
            $rawProps = (new Query())->from(Property::tableName())
                ->select(['id', 'key', 'storage_id', 'data_type'])
                ->where([
                    'id' => array_keys($workingProps),
                    'in_search' => 1
                ])
                ->all();
            $props = ArrayHelper::map($rawProps, 'id', 'key', 'storage_id');
            foreach ($storage as $className => $id) {
                if (false === isset($props[$id]) || true === empty($props[$id])) {
                    continue;
                }
                $indexData = self::prepareIndexData($className, $props[$id], $workingProps, $index, $model);
                if (false === empty($indexData)) {
                    $this->client->bulk($indexData);
                }
            }
        }
    }
protected function fillForModel ( $ index , $ model ) { if ( false === empty ( $ model -> propertiesIds ) && false === empty ( $ model -> propertiesValues ) ) { //leave only not empty properties $ workingProps = array_filter ( $ model -> propertiesValues , function ( $ e ) { if ( true === is_array ( $ e ) ) { foreach ( $ e as $ val ) { return ( count ( $ val ) > 0 && false === empty ( $ val [ 0 ] ) ) ; } } else { return false === empty ( $ e ) ; } } ) ; //collecting storages $ storage = ( new Query ( ) ) -> from ( PropertyStorage :: tableName ( ) ) -> select ( 'id' ) -> indexBy ( 'class_name' ) -> column ( ) ; //selecting all applicable properties to work with $ rawProps = ( new Query ( ) ) -> from ( Property :: tableName ( ) ) -> select ( [ 'id' , 'key' , 'storage_id' , 'data_type' ] ) -> where ( [ 'id' => array_keys ( $ workingProps ) , 'in_search' => 1 ] ) -> all ( ) ; $ props = ArrayHelper :: map ( $ rawProps , 'id' , 'key' , 'storage_id' ) ; foreach ( $ storage as $ className => $ id ) { if ( false === isset ( $ props [ $ id ] ) || true === empty ( $ props [ $ id ] ) ) { continue ; } $ indexData = self :: prepareIndexData ( $ className , $ props [ $ id ] , $ workingProps , $ index , $ model ) ; if ( false === empty ( $ indexData ) ) { $ this -> client -> bulk ( $ indexData ) ; } } } }
Performs model index filling

@param string $index
@param ActiveRecord | HasProperties | PropertiesTrait $model
Performs model index filling