xhinliang / elasticyii
ElasticSearch client for PHP 5.3 and Yii 1.1
v1.0.1
2016-07-29 07:40 UTC
Requires
- php: >=5.3.0
- yiisoft/yii: >=1.1.7
Requires (Dev)
- atoum/atoum: dev-master@dev
This package is not auto-updated.
Last update: 2025-01-08 20:18:15 UTC
README
ElasticSearch PHP client for Yii 1.1
Usage
Install
composer require xhinliang/elasticyii
Setup
Basic
Just add the component in your config/main.php
'components' => array(
'esclient' => array(
'class' => 'ElasticSearchClient',
),
),
Personalization
You can define your configurations in the config/main.php
'components' => array(
'esclient' => array(
'class' => 'ElasticSearchClient',
'config' => array(
'protocol' => 'http',
'servers' => '127.0.0.1:9200',
'index' => 'yourindex',
'type' => 'yourtype',
'timeout' => null,
)
),
),
protocol
This option will define the protocol ElasticYii will use.
http
means the http protocol, and the client will use ElasticSearchHTTP inside.memcached
means the memcached protocol, and the client will use ElasticSearchMemcached inside.
servers
The server ip and port. For example
'servers' => '222.22.22.44:9200'
default 127.0.0.1:9200
index
, type
the default index
and type
For example
'index' => 'yourindex',
'type' => 'yourtype',
timeout
the timeout, can be null
or a number.
'timeout' => 1000
Use
just enjoy it.
$esResult = Yii::app()->esclient
->setIndex("index")
->setType("type")
->index($json, $id);
$esResult = Yii::app()
->esclient
->setIndex($type)
->setType($group)
->get($id);
Licence
Copyright (c) 2010-2016 Xhin Liang
Copyright (c) 2010-2012 Raymond Julin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.