Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
4a17793d
Commit
4a17793d
authored
Aug 15, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new params to grouping component
parent
01ed9f94
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
1 deletion
+120
-1
library/Solarium/QueryType/Select/Query/Component/Grouping.php
...ry/Solarium/QueryType/Select/Query/Component/Grouping.php
+71
-0
library/Solarium/QueryType/Select/RequestBuilder/Component/Grouping.php
...um/QueryType/Select/RequestBuilder/Component/Grouping.php
+3
-0
tests/Solarium/Tests/QueryType/Select/Query/Component/GroupingTest.php
...m/Tests/QueryType/Select/Query/Component/GroupingTest.php
+39
-0
tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/GroupingTest.php
...ueryType/Select/RequestBuilder/Component/GroupingTest.php
+6
-0
tests/Solarium/Tests/QueryType/Select/RequestBuilder/RequestBuilderTest.php
...ts/QueryType/Select/RequestBuilder/RequestBuilderTest.php
+1
-1
No files found.
library/Solarium/QueryType/Select/Query/Component/Grouping.php
View file @
4a17793d
...
...
@@ -441,4 +441,75 @@ class Grouping extends Component
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'
);
}
}
library/Solarium/QueryType/Select/RequestBuilder/Component/Grouping.php
View file @
4a17793d
...
...
@@ -67,6 +67,9 @@ class Grouping
$request
->
addParam
(
'group.ngroups'
,
$component
->
getNumberOfGroups
());
$request
->
addParam
(
'group.cache.percent'
,
$component
->
getCachePercentage
());
$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
;
}
...
...
tests/Solarium/Tests/QueryType/Select/Query/Component/GroupingTest.php
View file @
4a17793d
...
...
@@ -58,6 +58,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'numberofgroups'
=>
true
,
'cachepercentage'
=>
45
,
'truncate'
=>
true
,
'function'
=>
'log(foo)'
,
'format'
=>
'grouped'
,
'facet'
=>
'true'
,
);
$this
->
grouping
->
setOptions
(
$options
);
...
...
@@ -71,6 +74,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$options
[
'numberofgroups'
],
$this
->
grouping
->
getNumberOfGroups
());
$this
->
assertEquals
(
$options
[
'cachepercentage'
],
$this
->
grouping
->
getCachePercentage
());
$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
()
...
...
@@ -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
()
);
}
}
tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/GroupingTest.php
View file @
4a17793d
...
...
@@ -52,6 +52,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
$component
->
setNumberOfGroups
(
false
);
$component
->
setCachePercentage
(
50
);
$component
->
setTruncate
(
true
);
$component
->
setFunction
(
'log(foo)'
);
$component
->
setFacet
(
true
);
$component
->
setFormat
(
'grouped'
);
$request
=
$builder
->
buildComponent
(
$component
,
$request
);
...
...
@@ -67,6 +70,9 @@ class GroupingTest extends \PHPUnit_Framework_TestCase
'group.ngroups'
=>
'false'
,
'group.cache.percent'
=>
50
,
'group.truncate'
=>
'true'
,
'group.func'
=>
'log(foo)'
,
'group.facet'
=>
true
,
'group.format'
=>
'grouped'
,
),
$request
->
getParams
()
);
...
...
tests/Solarium/Tests/QueryType/Select/RequestBuilder/RequestBuilderTest.php
View file @
4a17793d
...
...
@@ -177,7 +177,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'{!tag=t1,t2}cat:1'
,
$request
->
getParam
(
'q
uery
'
)
$request
->
getParam
(
'q'
)
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment