Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Elasticsearch DSL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Public
Elasticsearch DSL
Commits
f40fd130
Commit
f40fd130
authored
10 years ago
by
Martynas Sudintas
Browse files
Options
Downloads
Patches
Plain Diff
Added sub aggregations setter in AbstractAggregation
parent
1d50c2a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Aggregation/AbstractAggregation.php
+24
-5
24 additions, 5 deletions
Aggregation/AbstractAggregation.php
Aggregation/NestedAggregation.php
+1
-1
1 addition, 1 deletion
Aggregation/NestedAggregation.php
with
25 additions
and
6 deletions
Aggregation/AbstractAggregation.php
+
24
−
5
View file @
f40fd130
...
...
@@ -24,17 +24,17 @@ abstract class AbstractAggregation implements NamedBuilderInterface
/**
* @var string
*/
pr
otec
te
d
$field
;
pr
iva
te
$field
;
/**
* @var string
*/
pr
otec
te
d
$name
;
pr
iva
te
$name
;
/**
* @var NamedBuilderBag
*/
p
ublic
$aggregations
;
p
rivate
$aggregations
;
/**
* @return string
...
...
@@ -88,6 +88,26 @@ abstract class AbstractAggregation implements NamedBuilderInterface
return
self
::
PREFIX
.
$this
->
name
;
}
/**
* Adds a sub-aggregation.
*
* @param AbstractAggregation $abstractAggregation
*/
public
function
addAggregation
(
AbstractAggregation
$abstractAggregation
)
{
$this
->
aggregations
->
add
(
$abstractAggregation
);
}
/**
* Returns all sub aggregations.
*
* @return AbstractAggregation[]
*/
public
function
getAggregations
()
{
return
$this
->
aggregations
->
all
();
}
/**
* {@inheritdoc}
*/
...
...
@@ -114,8 +134,7 @@ abstract class AbstractAggregation implements NamedBuilderInterface
protected
function
collectNestedAggregations
()
{
$result
=
[];
$nested
=
$this
->
aggregations
->
all
();
foreach
(
$nested
as
$aggregation
)
{
foreach
(
$this
->
aggregations
->
all
()
as
$aggregation
)
{
$result
=
array_merge
(
$result
,
$aggregation
->
toArray
());
}
...
...
This diff is collapsed.
Click to expand it.
Aggregation/NestedAggregation.php
+
1
−
1
View file @
f40fd130
...
...
@@ -58,7 +58,7 @@ class NestedAggregation extends AbstractAggregation
*/
public
function
getArray
()
{
if
(
count
(
$this
->
a
ggregations
)
==
0
)
{
if
(
count
(
$this
->
getA
ggregations
()
)
==
0
)
{
throw
new
\LogicException
(
"Nested aggregation `
{
$this
->
getName
()
}
` has no aggregations added"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment