package.xml 0000664 0001750 0001750 00000015140 13160154425 011301 0 ustar jan jan
Horde_ElasticSearch
pear.horde.org
Horde ElasticSearch client
Lightweight API for ElasticSearch (http://www.elasticsearch.org/).
Chuck Hagenbuch
chuck
chuck@horde.org
yes
Jan Schneider
jan
jan@horde.org
yes
2017-09-19
1.0.4
1.0.0
stable
stable
BSD-2-Clause
* [jan] Mark PHP 7 as supported.
5.3.0
8.0.0alpha1
8.0.0alpha1
1.7.0
Horde_Exception
pear.horde.org
2.0.0
3.0.0alpha1
3.0.0alpha1
Horde_Http
pear.horde.org
2.0.0
3.0.0alpha1
3.0.0alpha1
2012-07-22
1.0.0beta1
1.0.0beta1
beta
beta
BSD-2-Clause
* First beta release for Horde 5.
1.0.0beta2
1.0.0beta1
beta
beta
2012-07-22
BSD-2-Clause
* [jan] Fix dependency on Horde_Http.
1.0.0
1.0.0
stable
stable
2012-10-30
BSD-2-Clause
* First stable release for Horde 5.
1.0.1
1.0.0
stable
stable
2012-11-19
BSD-2-Clause
* [mms] Use new Horde_Test layout.
1.0.2
1.0.0
stable
stable
2013-03-05
BSD-2-Clause
* [rla] Add license file.
1.0.3
1.0.0
stable
stable
2015-01-08
BSD-2-Clause
* [jan] Add Composer definition.
1.0.4
1.0.0
stable
stable
2017-09-19
BSD-2-Clause
* [jan] Mark PHP 7 as supported.
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/add.php 0000664 0001750 0001750 00000001250 13160154425 023051 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
$tweet = new Horde_ElasticSearch_Type('tweet', $twitter);
var_dump($tweet->add(1, '{
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?"
}'));
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/count.php 0000664 0001750 0001750 00000001053 13160154425 023452 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
$tweet = new Horde_ElasticSearch_Type('tweet', $twitter);
var_dump($tweet->count());
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/get.php 0000664 0001750 0001750 00000001053 13160154425 023101 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
$tweet = new Horde_ElasticSearch_Type('tweet', $twitter);
var_dump($tweet->get(1));
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/map.php 0000664 0001750 0001750 00000001160 13160154425 023076 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
$user = new Horde_ElasticSearch_Type('user', $twitter);
var_dump($user->map('{
"properties" : {
"name" : { "type" : "string" }
}
}'));
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/search.php 0000664 0001750 0001750 00000001071 13160154425 023567 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
$tweet = new Horde_ElasticSearch_Type('tweet', $twitter);
var_dump($tweet->search('elasticsearch'));
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/examples/status.php 0000664 0001750 0001750 00000001025 13160154425 023644 0 ustar jan jan
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package ElasticSearch
*/
require 'Horde/Autoloader/Default.php';
$client = new Horde_ElasticSearch_Client('http://localhost:9200/', new Horde_Http_Client());
var_dump($client->status());
$twitter = new Horde_ElasticSearch_Index('twitter', $client);
var_dump($twitter->status());
Horde_ElasticSearch-1.0.4/doc/Horde/ElasticSearch/COPYING 0000664 0001750 0001750 00000002447 13160154425 021036 0 ustar jan jan Copyright 2011-2017 Horde LLC (http://www.horde.org/). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HORDE PROJECT
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Horde_ElasticSearch-1.0.4/lib/Horde/ElasticSearch/Client.php 0000664 0001750 0001750 00000005300 13160154425 021722 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
/**
* ElasticSearch client class
*
* @author Chuck Hagenbuch
* @category Horde
* @copyright 2011-2017 Horde LLC
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
class Horde_ElasticSearch_Client
{
protected $_server = 'http://localhost:9200/';
protected $_httpClient;
public function __construct($server, Horde_Http_Client $httpClient)
{
$this->_server = $server;
$this->_httpClient = $httpClient;
}
/**
* curl -X GET {SERVER}/_status
*/
public function status($index = null)
{
return $this->_request($this->_path($index, '_status'));
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_search?q= ...
*/
public function search($index, $type, $q)
{
return $this->_request($this->_path($index, $type, '_search') . '?' . http_build_query(array('q' => $q)));
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE/{ID}
*/
public function get($index, $type, $id)
{
return $this->_request($this->_path($index, $type, $id));
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/{ID} -d ...
*/
public function add($index, $type, $id, $data)
{
return $this->_request($this->_path($index, $type, $id), 'PUT', $data);
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_count -d {matchAll:{}}
*/
public function count($index, $type)
{
return $this->_request($this->_path($index, $type, '_count'), 'GET', '{ matchAll:{} }');
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/_mapping -d ...
*/
public function map($index, $type, $data)
{
return $this->_request($this->_path($index, $type, '_mapping'), 'PUT', $data);
}
protected function _request($path, $method = 'GET', $data = null, $headers = array())
{
try {
$result = $this->_httpClient->request($method, $this->_server . $path, $data, $headers);
return json_decode($result->getBody());
} catch (Horde_Http_Exception $e) {
throw new Horde_ElasticSearch_Exception($e->getMessage(), $e->getCode(), $e);
}
}
protected function _path()
{
$path = array_filter(func_get_args());
foreach ($path as &$element) { $element = urlencode($element); }
return implode('/', $path);
}
}
Horde_ElasticSearch-1.0.4/lib/Horde/ElasticSearch/Exception.php 0000664 0001750 0001750 00000001207 13160154425 022444 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
/**
* ElasticSearch exceptions
*
* @author Chuck Hagenbuch
* @category Horde
* @copyright 2011-2017 Horde LLC
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
class Horde_ElasticSearch_Exception extends Horde_Exception
{
}
Horde_ElasticSearch-1.0.4/lib/Horde/ElasticSearch/Index.php 0000664 0001750 0001750 00000004235 13160154425 021561 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
/**
* ElasticSearch index class
*
* @author Chuck Hagenbuch
* @category Horde
* @copyright 2011-2017 Horde LLC
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
class Horde_ElasticSearch_Index
{
protected $_client;
protected $_index;
public function __construct($index, Horde_ElasticSearch_Client $client)
{
$this->_index = $index;
$this->_client = $client;
}
/**
* curl -X PUT {SERVER}/{INDEX}/
*/
public function create()
{
$this->_client->request(null, 'PUT');
}
/**
* curl -X DELETE {SERVER}/{INDEX}/
*/
public function drop()
{
$this->_client->request(null, 'DELETE');
}
/**
* curl -X GET {SERVER}/{INDEX}/_status
*/
public function status()
{
return $this->_client->status($this->_index);
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_search?q= ...
*/
public function search($type, $q)
{
return $this->_client->search($this->_index, $type, $q);
}
/**
* curl -XGET {SERVER}/{INDEX}/{TYPE/{ID}
*/
public function get($type, $id)
{
return $this->_client->get($this->_index, $type, $id);
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/{ID} -d ...
*/
public function add($type, $id, $data)
{
return $this->_client->add($this->_index, $type, $id, $data);
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_count -d {matchAll:{}}
*/
public function count($type)
{
return $this->_client->count($this->_index, $type);
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/_mapping -d ...
*/
public function map($type, $data)
{
return $this->_client->map($this->_index, $type, $data);
}
}
Horde_ElasticSearch-1.0.4/lib/Horde/ElasticSearch/Type.php 0000664 0001750 0001750 00000003212 13160154425 021425 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
/**
* ElasticSearch type class
*
* @author Chuck Hagenbuch
* @category Horde
* @copyright 2011-2017 Horde LLC
* @license http://www.horde.org/licenses/bsd BSD
* @package ElasticSearch
*/
class Horde_ElasticSearch_Type
{
protected $_type;
protected $_index;
public function __construct($type, Horde_ElasticSearch_Index $index)
{
$this->_type = $type;
$this->_index = $index;
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_search?q= ...
*/
public function search($q)
{
return $this->_index->search($this->_type, $q);
}
/**
* curl -XGET {SERVER}/{INDEX}/{TYPE/{ID}
*/
public function get($id)
{
return $this->_index->get($this->_type, $id);
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/{ID} -d ...
*/
public function add($id, $data)
{
return $this->_index->add($this->_type, $id, $data);
}
/**
* curl -X GET {SERVER}/{INDEX}/{TYPE}/_count -d {matchAll:{}}
*/
public function count()
{
return $this->_index->count($this->_type);
}
/**
* curl -X PUT {SERVER}/{INDEX}/{TYPE}/_mapping -d ...
*/
public function map($data)
{
return $this->_index->map($this->_type, $data);
}
}