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条)

报告相同问题?

悬赏问题

  • ¥18 模拟电路问题解答有偿
  • ¥15 Matlab在app上输入带有矩阵形式的初始条件发生错误
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题