https://github.com/trk54ylmz/elasticsearch-php-thrift
ElasticSearch PHP Thrift Client
https://github.com/trk54ylmz/elasticsearch-php-thrift
elasticsearch php thrift-transport-plugin
Last synced: 26 days ago
JSON representation
ElasticSearch PHP Thrift Client
- Host: GitHub
- URL: https://github.com/trk54ylmz/elasticsearch-php-thrift
- Owner: trK54Ylmz
- License: gpl-2.0
- Created: 2014-04-01T21:50:21.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-17T07:09:19.000Z (over 10 years ago)
- Last Synced: 2025-04-01T09:11:08.259Z (2 months ago)
- Topics: elasticsearch, php, thrift-transport-plugin
- Language: Shell
- Homepage:
- Size: 1.02 MB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Elasticsearch PHP Thrift transport client
========================Low-level Elasticsearch Thrift transport plugin. The library is compatible with Elasticsearch 1.3.X
## Requirements
* Apache Thrift 0.9 or higher
* Elasticsearch 1.0.0 or higher with Thrift transport plugin[https://github.com/elasticsearch/elasticsearch-transport-thrift]
## Performance
Elasticsearch Thrift Client (Thrift extension installed) almost **3x** times faster than Elasticsearch Official PHP Client
## Usage
1. Install Thrift C++ Transport Extension for **performance** (Optional but recommended)
```shell
cd lib/ThriftExt/thrift_protocol
phpize --clean && phpize
./configure
make
sudo make install
```
2. Create `composer.json`:```json
{
"require" : {
"trk54ylmz/elasticsearch-thrift": "dev-master"
}
}
```
3. Include `vendor/autoload.php`### Search
```php
require 'vendor/autoload.php';$elasticsearch = new Elasticsearch\Client();
$body = '
{
"query" : {
"match_all" : {}
}
}
';$elasticsearch->setIndex('twitter');
$elasticsearch->setType('users');
$elasticsearch->setBody($body);$result = $elasticsearch->search();
var_dump($result->hits);
```### Index a document
```php
$elasticsearch = new Elasticsearch\Client();$body = array(
'username' => 'trK54Ylmz',
'email' => '[email protected]',
'country' => 'TR',
'logged' => false
);$elasticsearch->setIndex('twitter');
$elasticsearch->setType('users');
$elasticsearch->setBody($body);$result = $elasticsearch->index();
```### Get a document
```php
$elasticsearch = new Elasticsearch\Client();$elasticsearch->setIndex('twitter');
$elasticsearch->setType('users');
$elasticsearch->setId('1');$result = $elasticsearch->get();
```### Update a document
```php
$elasticsearch = new Elasticsearch\Client();$body = array(
'doc' => array(
'logged' => false
)
);$elasticsearch->setIndex('twitter');
$elasticsearch->setType('users');
$elasticsearch->setId('1');
$elasticsearch->setBody($body);$elasticsearch->update();
```### Delete a document
```php
$elasticsearch = new Elasticsearch\Client();$elasticsearch->setIndex('twitter');
$elasticsearch->setType('users');
$elasticsearch->setId('1');$elasticsearch->delete();
```## Todo
1. Advanced DSL
2. Mapping feature
3. Cluster management