Created
August 30, 2011 22:50
-
-
Save phillro/1182323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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