dongtidai6519 2012-03-06 15:40
浏览 126
已采纳

如何从“Elastica ResultSet”对象获取结果

I am using the "elastica" php client for ElasticSearch.

I'm a bit new to OO-programming, especially in php.

However, I have managed to search my elasticsearch server using the elastica php client and store the response in an "Elastica_ResultSet" object. I have had no luck accessing the contents of that object whatsoever.

I would like to be able to list the total number of results, find an elasticsearch record id of a result and get the full content of an elasticsearch record for that result.

The Elastica class reference can be found here http://ruflin.github.com/Elastica/api/index.html , although I don't know what to do with it.

Here is the php code I have been using to get this far:

<?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');
?>
  • 写回答

2条回答 默认 最新

  • duanjianshen4871 2012-05-25 02:22
    关注

    After a couple of months OO practise, it seemed performing a simple var_dump($resultSet) would have provided me with the structure and contents of the returned object... can't believe that nobody made any suggestions for such a basic question ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog