bostjanob / solr-client
This package is abandoned and no longer maintained.
The author suggests using the solarium/solarium package instead.
Apache SOLR client for ZF2
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
Features :
- Adding, updating and deleting documents
- Query builder
- Facets
- Spellcheck
- Zend Developer Toolbar plugin
Requirements
- Zend Framework 2
- [Apache Solr] (http://lucene.apache.org/solr/)
- CURL module enabled in php
In your solrconfig.xml you must have php serialized query response writer enabled:
<queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>
Installation
- Add
"bostjanob/solr-client": "dev-master"
to yourcomposer.json
- Run
php composer.phar install
- Enable the module in your
config/application.config.php
by addingSolrClient
tomodules
Setting up your connection
Setup your connection by adding the module configuration to any valid ZF2 config file. This can be any file in autoload/ or a module configuration (such as the Application/config/module.config.php file).
<?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' ), ), ), );
Getting SolrClient
Access the solrClient using the following alias:
$client = $this->getServiceLocator()->get('solr.solr_default');
Inserting or updating documents
Coming soon...
Deleting documents
Deleting documents by 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();
Commit, optimize
More info about "commit" and "optimize"
Commit
public function commit($optimize = false, $waitFlush = true, $waitSearcher = true)
Optimize
public function optimize($waitFlush = true, $waitSearcher = true, $maxSegments = 1)
Query builder
Coming soon...