bostjanob/solr-client

此包已被弃用且不再维护。作者建议使用 solarium/solarium 包。

Apache SOLR 客户端 for ZF2

dev-master 2017-01-24 06:59 UTC

This package is auto-updated.

Last update: 2022-02-01 12:21:25 UTC


README

Apache Solr Client for Zend Framework 2

功能

  • 添加、更新和删除文档
  • 查询构建器
  • 分面
  • 拼写检查
  • Zend 开发者工具栏插件

要求

  1. Zend Framework 2
  2. [Apache Solr] (http://lucene.apache.org/solr/)
  3. php 中启用 CURL 模块

在您的 solrconfig.xml 中,您必须启用 php 序列化查询响应编写器:<queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>

安装

  1. "bostjanob/solr-client": "dev-master" 添加到您的 composer.json
  2. 运行 php composer.phar install
  3. 通过在 config/application.config.php 中添加 SolrClientmodules 来启用模块

设置连接

通过将模块配置添加到任何有效的 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)

查询构建器

即将推出...