【发布时间】:2012-03-24 02:53:08
【问题描述】:
我正在为 ElasticSearch 使用“elastica”php 客户端。
我对 OO 编程有点陌生,尤其是 php。
但是,我已经设法使用 elastica php 客户端搜索我的 elasticsearch 服务器,并将响应存储在“Elastica_ResultSet”对象中。我无法访问该对象的内容。
我希望能够列出结果总数,找到结果的弹性搜索记录 id 并获取该结果的弹性搜索记录的完整内容。
Elastica 类参考可以在这里找到http://ruflin.github.com/Elastica/api/index.html,虽然我不知道如何处理它。
这是我一直使用的 php 代码:
<?php
function __autoload_elastica ($class) {
$path = str_replace('_', '/', $class);
if (file_exists('extentions/' . $path . '.php')) {
require_once('extentions/' . $path . '.php');
//echo "$path EXISTS!!!";
}
}
spl_autoload_register('__autoload_elastica');
// New ES Client
$client = new Elastica_Client();
// Set Index
$index = $client->getIndex('test1');
// Set Document Type
$type = $index->getType('user');
// Perform Search
$resultSet = $index->search('halo');
?>
【问题讨论】:
标签: php object elasticsearch