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
ba27ed04
Commit
ba27ed04
authored
Dec 20, 2016
by
chadicus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Grouping::extractValueGroup
parent
82064281
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
22 deletions
+37
-22
library/Solarium/QueryType/Select/ResponseParser/Component/Grouping.php
...um/QueryType/Select/ResponseParser/Component/Grouping.php
+37
-22
No files found.
library/Solarium/QueryType/Select/ResponseParser/Component/Grouping.php
View file @
ba27ed04
...
...
@@ -83,28 +83,7 @@ class Grouping implements ComponentParserInterface
$groupCount
=
(
isset
(
$result
[
'ngroups'
]))
?
$result
[
'ngroups'
]
:
null
;
$valueGroups
=
array
();
foreach
(
$result
[
'groups'
]
as
$valueGroupResult
)
{
$value
=
(
isset
(
$valueGroupResult
[
'groupValue'
]))
?
$valueGroupResult
[
'groupValue'
]
:
null
;
$numFound
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'numFound'
]))
?
$valueGroupResult
[
'doclist'
][
'numFound'
]
:
null
;
$start
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'start'
]))
?
$valueGroupResult
[
'doclist'
][
'start'
]
:
null
;
$maxScore
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'maxScore'
]))
?
$valueGroupResult
[
'doclist'
][
'maxScore'
]
:
null
;
// create document instances
$documents
=
array
();
if
(
isset
(
$valueGroupResult
[
'doclist'
][
'docs'
])
&&
is_array
(
$valueGroupResult
[
'doclist'
][
'docs'
]))
{
foreach
(
$valueGroupResult
[
'doclist'
][
'docs'
]
as
$doc
)
{
$documents
[]
=
new
$documentClass
(
$doc
);
}
}
$valueGroups
[]
=
new
$valueResultClass
(
$value
,
$numFound
,
$start
,
$documents
,
$maxScore
,
$query
);
$valueGroups
[]
=
$this
->
extractValueGroup
(
$valueResultClass
,
$documentClass
,
$valueGroupResult
,
$query
);
}
$groups
[
$field
]
=
new
FieldGroup
(
$matches
,
$groupCount
,
$valueGroups
);
...
...
@@ -139,4 +118,40 @@ class Grouping implements ComponentParserInterface
return
new
Result
(
$groups
);
}
/**
* Helper method to extract a ValueGroup object from the given value group result array.
*
* @param string $valueResultClass The grouping resultvaluegroupclass option.
* @param string $documentClass The name of the solr document class to use.
* @param array $valueGroupResult The group result from the solr response.
* @param Query $query The current solr query.
*
* @return object
*/
private
function
extractValueGroup
(
$valueResultClass
,
$documentClass
,
$valueGroupResult
,
$query
)
{
$value
=
(
isset
(
$valueGroupResult
[
'groupValue'
]))
?
$valueGroupResult
[
'groupValue'
]
:
null
;
$numFound
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'numFound'
]))
?
$valueGroupResult
[
'doclist'
][
'numFound'
]
:
null
;
$start
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'start'
]))
?
$valueGroupResult
[
'doclist'
][
'start'
]
:
null
;
$maxScore
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'maxScore'
]))
?
$valueGroupResult
[
'doclist'
][
'maxScore'
]
:
null
;
// create document instances
$documents
=
array
();
if
(
isset
(
$valueGroupResult
[
'doclist'
][
'docs'
])
&&
is_array
(
$valueGroupResult
[
'doclist'
][
'docs'
]))
{
foreach
(
$valueGroupResult
[
'doclist'
][
'docs'
]
as
$doc
)
{
$documents
[]
=
new
$documentClass
(
$doc
);
}
}
return
new
$valueResultClass
(
$value
,
$numFound
,
$start
,
$documents
,
$maxScore
,
$query
);
}
}
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