Commit 4a17793d authored by Bas de Nooijer's avatar Bas de Nooijer

Added new params to grouping component

parent 01ed9f94
...@@ -441,4 +441,75 @@ class Grouping extends Component ...@@ -441,4 +441,75 @@ class Grouping extends Component
return $this->getOption('truncate'); return $this->getOption('truncate');
} }
/**
* Set function option
*
* Group based on the unique values of a function query. Only available in Solr 4.0+
*
* @param string $value
* @return self Provides fluent interface
*/
public function setFunction($value)
{
return $this->setOption('function', $value);
}
/**
* Get truncate option
*
* @return string|null
*/
public function getFunction()
{
return $this->getOption('function');
}
/**
* Set facet option
*
* Group based on the unique values of a function query.
* This parameter only is supported on Solr 4.0+
*
* @param string $value
* @return self Provides fluent interface
*/
public function setFacet($value)
{
return $this->setOption('facet', $value);
}
/**
* Get facet option
*
* @return string|null
*/
public function getFacet()
{
return $this->getOption('facet');
}
/**
* Set format option
*
* If simple, the grouped documents are presented in a single flat list.
* The start and rows parameters refer to numbers of documents instead of numbers of groups.
*
* @param string $value
* @return self Provides fluent interface
*/
public function setFormat($value)
{
return $this->setOption('format', $value);
}
/**
* Get format option
*
* @return string|null
*/
public function getFormat()
{
return $this->getOption('format');
}
} }
...@@ -67,6 +67,9 @@ class Grouping ...@@ -67,6 +67,9 @@ class Grouping
$request->addParam('group.ngroups', $component->getNumberOfGroups()); $request->addParam('group.ngroups', $component->getNumberOfGroups());
$request->addParam('group.cache.percent', $component->getCachePercentage()); $request->addParam('group.cache.percent', $component->getCachePercentage());
$request->addParam('group.truncate', $component->getTruncate()); $request->addParam('group.truncate', $component->getTruncate());
$request->addParam('group.func', $component->getFunction());
$request->addParam('group.facet', $component->getFacet());
$request->addParam('group.format', $component->getFormat());
return $request; return $request;
} }
......
...@@ -58,6 +58,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -58,6 +58,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'numberofgroups' => true, 'numberofgroups' => true,
'cachepercentage' => 45, 'cachepercentage' => 45,
'truncate' => true, 'truncate' => true,
'function' => 'log(foo)',
'format' => 'grouped',
'facet' => 'true',
); );
$this->grouping->setOptions($options); $this->grouping->setOptions($options);
...@@ -71,6 +74,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -71,6 +74,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($options['numberofgroups'], $this->grouping->getNumberOfGroups()); $this->assertEquals($options['numberofgroups'], $this->grouping->getNumberOfGroups());
$this->assertEquals($options['cachepercentage'], $this->grouping->getCachePercentage()); $this->assertEquals($options['cachepercentage'], $this->grouping->getCachePercentage());
$this->assertEquals($options['truncate'], $this->grouping->getTruncate()); $this->assertEquals($options['truncate'], $this->grouping->getTruncate());
$this->assertEquals($options['function'], $this->grouping->getFunction());
$this->assertEquals($options['format'], $this->grouping->getFormat());
$this->assertEquals($options['facet'], $this->grouping->getFacet());
} }
public function testGetType() public function testGetType()
...@@ -223,4 +229,37 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -223,4 +229,37 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
); );
} }
public function testSetAndGetFunction()
{
$value = 'log(foo)';
$this->grouping->setFunction($value);
$this->assertEquals(
$value,
$this->grouping->getFunction()
);
}
public function testSetAndGetFormat()
{
$value = 'grouped';
$this->grouping->setFormat($value);
$this->assertEquals(
$value,
$this->grouping->getFormat()
);
}
public function testSetAndGetFacet()
{
$value = true;
$this->grouping->setFacet($value);
$this->assertEquals(
$value,
$this->grouping->getFacet()
);
}
} }
...@@ -52,6 +52,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -52,6 +52,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
$component->setNumberOfGroups(false); $component->setNumberOfGroups(false);
$component->setCachePercentage(50); $component->setCachePercentage(50);
$component->setTruncate(true); $component->setTruncate(true);
$component->setFunction('log(foo)');
$component->setFacet(true);
$component->setFormat('grouped');
$request = $builder->buildComponent($component, $request); $request = $builder->buildComponent($component, $request);
...@@ -67,6 +70,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase ...@@ -67,6 +70,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'group.ngroups' => 'false', 'group.ngroups' => 'false',
'group.cache.percent' => 50, 'group.cache.percent' => 50,
'group.truncate' => 'true', 'group.truncate' => 'true',
'group.func' => 'log(foo)',
'group.facet' => true,
'group.format' => 'grouped',
), ),
$request->getParams() $request->getParams()
); );
......
...@@ -177,7 +177,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -177,7 +177,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
'{!tag=t1,t2}cat:1', '{!tag=t1,t2}cat:1',
$request->getParam('query') $request->getParam('q')
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment