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
d18b247a
Commit
d18b247a
authored
10 years ago
by
Mantas Jonušas
Browse files
Options
Downloads
Patches
Plain Diff
Added more tests, fixed query formating bug in date range aggregation
parent
1824e778
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/DateRangeAggregation.php
+13
-10
13 additions, 10 deletions
Aggregation/DateRangeAggregation.php
Aggregation/MissingAggregation.php
+1
-2
1 addition, 2 deletions
Aggregation/MissingAggregation.php
with
14 additions
and
12 deletions
Aggregation/DateRangeAggregation.php
+
13
−
10
View file @
d18b247a
...
...
@@ -58,16 +58,19 @@ class DateRangeAggregation extends AbstractAggregation
*/
public
function
addRange
(
$from
=
null
,
$to
=
null
)
{
if
(
$from
===
null
&&
$to
===
null
)
{
throw
new
\LogicException
(
'Missing range'
);
}
elseif
(
$from
===
null
)
{
$this
->
ranges
=
[[
'to'
=>
$to
]];
}
elseif
(
$to
===
null
)
{
$this
->
ranges
=
[[
'from'
=>
$from
]];
}
else
{
$this
->
ranges
=
[[
'from'
=>
$from
],
[
'to'
=>
$to
]];
$range
=
array_filter
(
[
'from'
=>
$from
,
'to'
=>
$to
,
]
);
if
(
empty
(
$range
))
{
throw
new
\LogicException
(
'Either from or to must be set. Both cannot be null.'
);
}
$this
->
ranges
[]
=
$range
;
return
$this
;
}
...
...
@@ -80,12 +83,12 @@ class DateRangeAggregation extends AbstractAggregation
$data
=
[
'format'
=>
$this
->
getFormat
(),
'field'
=>
$this
->
getField
(),
'ranges'
=>
array_values
(
$this
->
ranges
)
,
'ranges'
=>
$this
->
ranges
,
];
return
$data
;
}
throw
new
\LogicException
(
'Date range aggregation must have field
and
format set.'
);
throw
new
\LogicException
(
'Date range aggregation must have field
,
format set
and range added
.'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Aggregation/MissingAggregation.php
+
1
−
2
View file @
d18b247a
...
...
@@ -12,7 +12,6 @@
namespace
ONGR\ElasticsearchBundle\DSL\Aggregation
;
use
ONGR\ElasticsearchBundle\DSL\Aggregation\Type\BucketingTrait
;
use
Symfony\Component\Process\Exception\LogicException
;
/**
* Class representing missing aggregation.
...
...
@@ -29,7 +28,7 @@ class MissingAggregation extends AbstractAggregation
if
(
$this
->
getField
())
{
return
[
'field'
=>
$this
->
getField
()];
}
throw
new
LogicException
(
'Missing aggregation must have a field set'
);
throw
new
\
LogicException
(
'Missing aggregation must have a field set
.
'
);
}
/**
...
...
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