W3cubDocs

/PHP

SolrQuery::setExpand

(PECL solr >= 2.2.0)

SolrQuery::setExpandEnables/Disables the Expand Component

Description

public SolrQuery SolrQuery::setExpand ( bool $value )

Enables/Disables the Expand Component.

Parameters

value

Bool flag

Return Values

SolrQuery

Examples

Example #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;

?>

The above example will output something similar to:

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

See Also

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/solrquery.setexpand.php