Skip to content

Instantly share code, notes, and snippets.

@phillro
Created August 30, 2011 22:50
Show Gist options
  • Save phillro/1182323 to your computer and use it in GitHub Desktop.
Save phillro/1182323 to your computer and use it in GitHub Desktop.
<?php
//This example was adapted from the documentation available at https://github.com/ruflin/Elastica
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/Elastica/lib'));
function elasticsearch_autoload($class) {
$file = str_replace('_', '/', $class) . '.php';
require_once $file;
}
spl_autoload_register('elasticsearch_autoload');
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__)));
$userName='YOURUSERNAME';
$password='YOURPASSWORD';
$indexName='YOURINDEXNAME';
$config = array(
'host' => 'esh01.elasticsearchhq.com',
'port' => '80',
'transport' => 'http',
);
$client = new Elastica_Client($config);
$index = $client->getIndex($indexName);
$resultSet = $index->search('');
echo var_export($resultSet, true);
function encodeAuth($userName, $password){
$encodedAuth = base64_encode($userName.':'.$password);
return $encodedAuth;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment