首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在solr中使用solarium进行分页?

如何在solr中使用solarium进行分页?
EN

Stack Overflow用户
提问于 2013-07-06 17:37:09
回答 1查看 3.2K关注 0票数 3

我正在使用solrium,一个PHP Solr客户端,用于在PHP中使用Solr,我能够使用select等查询。当我使用select时,我只得到了10个结果,而在Solr的默认配置中,这10个结果被设置为10,我如何获得所有的结果,并在结果处进行分页?

下面是代码

代码语言:javascript
复制
<?php



require('/var/www/lg/vendor/solarium/solarium/examples/init.php');

htmlHeader();

// create a client instance
$client = new Solarium\Client($config);


// get a select query instance
$query = $client->createQuery($client::QUERY_SELECT);




// this executes the query and returns the result
$resultset = $client->execute($query);


// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();

// show documents using the resultset iterator
foreach ($resultset as $document) {


$query->setStart(2)->setRows(10);

//$query->setStart(21)->setRows(30);
    echo '<hr/><table>';

    // the documents are also iterable, to get all fields
    foreach($document AS $field => $value)
    {
        // this converts multivalue fields to a comma-separated string
        if(is_array($value)) $value = implode(', ', $value);

        echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
    }

    echo '</table>';
}

//new PageRequest(0, 10)

htmlFooter();





?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-06 17:48:34

你可以像这样做:$query->setStart(2)->setRows(20)看看这个例子:http://wiki.solarium-project.org/index.php/V3:Usage_modes

下面是关于您可以提供的选项的更多信息:http://wiki.solarium-project.org/index.php/V2:Building_a_select_query

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17501630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档