【问题标题】:how to use scroll in foselasticabundle?如何在 foselasticabundle 中使用滚动?
【发布时间】:2021-11-13 19:45:42
【问题描述】:

我想知道如何在 foselasticabundle 中设置滚动?我有这个代码

$res = $this->commentIndex->createSearch($query, ['scroll' => '1m']);
 $res->addType('reading');
 $res->scroll();

我知道我已经接近获得我的查询结果。你能帮我用 foselasticabundle 中的哪个函数来显示我的查询结果吗?我正在尝试深入研究 foselasticabundle 的代码。

【问题讨论】:

    标签: php elasticsearch foselasticabundle


    【解决方案1】:

    我在link找到了问题的答案

    我在链接中有同样的代码

    $search = $this->commentIndex->createSearch();
    $search->addType('reading');
    $search->setQuery($query);
    $scroll = new \Elastica\Scroll($search);
    $results = [];
    
    
    foreach ($scroll as $scrollId => $resultSet) {
          foreach ($resultSet->getDocuments() as $doc) {
             $results[$doc->getId()] = $doc;
          }
       }
    

    到目前为止,在这种方法中,我可以获得滚动 ID 和我需要的结果。但是,如果您找到了另一种方式,希望您可以将其发布在此问题中。

    【讨论】:

      猜你喜欢
      • 2014-03-17
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多