array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'solrquery.setexpand.php', 1 => 'SolrQuery::setExpand', 2 => 'Enables/Disables the Expand Component', ), 'up' => array ( 0 => 'class.solrquery.php', 1 => 'SolrQuery', ), 'prev' => array ( 0 => 'solrquery.setechoparams.php', 1 => 'SolrQuery::setEchoParams', ), 'next' => array ( 0 => 'solrquery.setexpandquery.php', 1 => 'SolrQuery::setExpandQuery', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/solr/solrquery/setexpand.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PECL solr >= 2.2.0)
SolrQuery::setExpand — Enables/Disables the Expand Component
valueBool flag
示例 #1 SolrQuery::setExpand() example
<?php
$query = new SolrQuery('lucene');
$query
    ->setExpand(true)
    ->setExpandRows(50)
    ->setExpandQuery('text:product')
    ->addExpandFilterQuery('manu:apple')
    ->addExpandFilterQuery('inStock:true')
    ->addExpandSortField('score', SolrQuery::ORDER_DESC)
    ->addExpandSortField('title', SolrQuery::ORDER_ASC);
echo $query.PHP_EOL;
?>以上示例的输出类似于:
q=lucene&expand=true&expand.rows=50&expand.q=text:product&expand.fq=manu:apple&expand.fq=inStock:true&expand.sort=score desc,title asc