bostjanob / solr-client
dev-master
2017-01-24 06:59 UTC
Requires
- php: >=5.3.3
- zendframework/zendframework: 2.*
Requires (Dev)
- zendframework/zend-developer-tools: dev-master
Suggests
- zendframework/zend-developer-tools: zend-developer-tools if you want to profile operations executed by the client during development
This package is auto-updated.
Last update: 2022-02-01 12:21:25 UTC
README
Apache Solr Client for Zend Framework 2
功能
- 添加、更新和删除文档
- 查询构建器
- 分面
- 拼写检查
- Zend 开发者工具栏插件
要求
- Zend Framework 2
- [Apache Solr] (http://lucene.apache.org/solr/)
- php 中启用 CURL 模块
在您的 solrconfig.xml 中,您必须启用 php 序列化查询响应编写器:<queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>
安装
- 将
"bostjanob/solr-client": "dev-master"
添加到您的composer.json
- 运行
php composer.phar install
- 通过在
config/application.config.php
中添加SolrClient
到modules
来启用模块
设置连接
通过将模块配置添加到任何有效的 ZF2 配置文件中设置您的连接。这可以是 autoload/ 中的任何文件或模块配置(如 Application/config/module.config.php 文件)。
<?php return array( 'solr' => array( 'connection' => array( 'solr_default' => array( 'host' => 'HOSTNAME', 'port' => 'PORT', // for basic auth 'user' => 'USERNAME', 'password' => 'PASSWORD', // web path where solr is installed 'path' => '/', // scheme: http or https 'scheme' => 'http' ), ), ), );
获取 SolrClient
使用以下别名访问 solrClient
$client = $this->getServiceLocator()->get('solr.solr_default');
插入或更新文档
即将推出...
删除文档
通过 ID 删除文档
$solrClient->deleteById(1); $solrClient->commit(); // more documents at once, and commit $solrClient->deleteById(array(1,2,3,4), true); //or all data $solrClient->deleteByQuery("*:*"); $solrClient->commit();
提交,优化
提交
public function commit($optimize = false, $waitFlush = true, $waitSearcher = true)
优化
public function optimize($waitFlush = true, $waitSearcher = true, $maxSegments = 1)
查询构建器
即将推出...