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
0f24a616
Commit
0f24a616
authored
9 years ago
by
Aivaras Gotovskis
Browse files
Options
Downloads
Patches
Plain Diff
Add range aggregation doc.
parent
d4de47f7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/Aggregation/Range.md
+82
-0
82 additions, 0 deletions
docs/Aggregation/Range.md
with
82 additions
and
0 deletions
docs/Aggregation/Range.md
0 → 100644
+
82
−
0
View file @
0f24a616
# Range Aggregation
> More info about range aggregation is in the [official elasticsearch docs][1]
A multi-bucket value source based aggregation that enables the user to define a set of
ranges - each representing a bucket.
## Simple example
```
JSON
{
"aggs" : {
"agg_price_ranges" : {
"range" : {
"field" : "price",
"ranges" : [
{ "to" : 50 },
{ "from" : 50, "to" : 100 },
{ "from" : 100 }
]
}
}
}
}
```
And now the query via DSL:
```
php
$rangeAggregation
=
new
RangeAggregation
(
'price_ranges'
,
'price'
,
[
[
'to'
=>
50
],
[
'from'
=>
50
,
'to'
=>
100
],
[
'from'
=>
100
],
]
);
$search
=
new
Search
();
$search
->
addAggregation
(
$rangeAggregation
);
$queryArray
=
$search
->
toArray
();
```
## Keyed example
```
php
$rangeAggregation
=
new
RangeAggregation
(
'price_ranges'
,
'price'
,
[
[
'key'
=>
'cheap'
,
'to'
=>
50
],
[
'from'
=>
50
,
'to'
=>
100
],
[
'key'
=>
'expensive'
,
'from'
=>
100
],
],
true
);
$search
=
new
Search
();
$search
->
addAggregation
(
$rangeAggregation
);
$queryArray
=
$search
->
toArray
();
```
## Adder example
```
php
$rangeAggregation
=
new
RangeAggregation
(
'price_ranges'
,
'price'
);
$rangeAggregation
->
setKeyed
(
true
);
$rangeAggregation
->
addRange
(
null
,
50
,
'cheap'
);
$rangeAggregation
->
addRange
(
50
,
100
);
$rangeAggregation
->
addRange
(
100
,
null
,
'expensive'
);
$search
=
new
Search
();
$search
->
addAggregation
(
$rangeAggregation
);
$queryArray
=
$search
->
toArray
();
```
[
1
]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
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