opendi/solrclient
最新稳定版本:1.3.0
Composer 安装命令:
composer require opendi/solrclient
包简介
Client for Apache Solr
关键字:
README 文档
README
Classes for the busy PHP developer to work with Apache Solr.
Requirements
This package requires at least PHP 5.5.9.
Construction
First, you must construct a Guzzle HTTP client and set the base_uri option to
the Solr endpoint you wish to work with. Then use it to create a Solr Client.
use Opendi\Solr\Client\Client; $guzzle = new \GuzzleHttp\Client([ 'base_uri' => "http://localhost:8983/solr/" ]); $client = new Client($guzzle);
It's also possible to pass some default request options, such as headers and timeouts to the Guzzle client.
use Opendi\Solr\Client\Client; $guzzle = new \GuzzleHttp\Client([ 'base_uri' => "http://localhost:8983/solr/", 'defaults' => [ 'timeout' => 10 ] ]); $solr = new Client($guzzle);
See Guzzle documentation for all options.
There is a helper factory($url, $defaults) static method which does the same
as above.
use Opendi\Solr\Client\Client; $solr = Client::factory('http://localhost:8983/solr/', [ 'timeout' => 10 ]);
Working with cores
A core is solar terminology for a collection of records. To select a core, use
the core($name) method on the Solr Client.
$core = $client->core('places'); // Perform a select query $select = Solr::select()->search('name:Franz'); $client->core('places')->select($select); // Perform an update query $update = Solr::update()->body('{}'); $client->core('places')->update($update);
The Core object offers some helper methods:
// Returns core status $client->core('places')->status(); // Returns number of documents in a core $client->core('places')->count(); // Deletes all records in the core $client->core('places')->deleteAll(); // Deletes records matching a selector $client->core('places')->deleteByQuery('name:Opendi'); // Deletes record with the given ID $client->core('places')->deleteByID('100'); // Checks the core is up $client->core('places')->ping(); // Optimizes core documents $client->core('places')->optimize(); // Commits inserted documents $client->core('places')->commit();
统计信息
- 总下载量: 2.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2014-06-22