徐辉煌 / elasticyii
ElasticSearch 客户端,适用于 PHP 5.3 和 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: 2024-09-18 19:00:38 UTC
README
适用于 Yii 1.1 的 ElasticSearch PHP 客户端
使用方法
安装
composer require xhinliang/elasticyii
配置
基础
只需在您的 config/main.php
文件中添加组件
'components' => array(
'esclient' => array(
'class' => 'ElasticSearchClient',
),
),
个性化
您可以在 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,
)
),
),
协议
此选项将定义 Elasticyii 将使用的协议。
http
表示 http 协议,客户端将使用 ElasticSearchHTTP。memcached
表示 memcached 协议,客户端将使用 ElasticSearchMemcached。
服务器
服务器 IP 和端口号。例如
'servers' => '222.22.22.44:9200'
默认 127.0.0.1:9200
index
,type
默认 index
和 type
。例如
'index' => 'yourindex',
'type' => 'yourtype',
超时
超时时间,可以是 null
或一个数字。
'timeout' => 1000
使用
尽情享受吧。
$esResult = Yii::app()->esclient
->setIndex("index")
->setType("type")
->index($json, $id);
$esResult = Yii::app()
->esclient
->setIndex($type)
->setType($group)
->get($id);
许可证
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.