Created
August 15, 2011 17:23
-
-
Save phillro/1147250 to your computer and use it in GitHub Desktop.
Elastica search example
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 | |
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__))); | |
$config = array( | |
'host' => 'esh01.elasticsearchhq.com', | |
'port' => '80', | |
); | |
$client = new Elastica_Client($config); | |
$index = $client->getIndex(YOUR_INDEX_NAME); | |
$resultSet = $index->search('some search term or query'); | |
echo var_export($resultSet, true); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment