PHP code example of xhinliang / elasticyii

1. Go to this page and download the library: Download xhinliang/elasticyii library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xhinliang / elasticyii example snippets


'components' => array(
    'esclient' => array(
        'class' => 'ElasticSearchClient',
    ),
),

'components' => array(
    'esclient' => array(
        'class' => 'ElasticSearchClient',
        'config' => array(
            'protocol' => 'http',
            'servers' => '127.0.0.1:9200',
            'index' => 'yourindex',
            'type' => 'yourtype',
            'timeout' => null,
        )
    ),
),

$esResult = Yii::app()->esclient
    ->setIndex("index")
    ->setType("type")
    ->index($json, $id);
    
$esResult = Yii::app()
    ->esclient
    ->setIndex($type)
    ->setType($group)
    ->get($id);