-
Notifications
You must be signed in to change notification settings - Fork 20
Add support for range agg #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mitep
wants to merge
8
commits into
lambdaworks:main
Choose a base branch
from
Mitep:task-add-support-for-range-agg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c641f1a
Support Range aggregation
Mitep 40ed18d
Update ElasticAggregationSpec
Mitep 841697f
Add docs
Mitep b5cd542
Support constructing ranges for Scala 2.12
Mitep bb19bfd
Update Aggregation tests
Mitep c1f9ddc
Fix Json decoders
Mitep ddce4fb
Update docs
Mitep 228ef56
Address code remarks
Mitep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
id: elastic_aggregation_range | ||
title: "Range Aggregation" | ||
--- | ||
|
||
The `Range` aggregation is a multi-value aggregation enables the user to define a set of ranges. During the aggregation process, the values extracted from each document will be checked against each bucket range. | ||
|
||
In order to use the `Range` aggregation import the following: | ||
```scala | ||
import zio.elasticsearch.aggregation.RangeAggregation | ||
import zio.elasticsearch.ElasticAggregation.RangeAggregation | ||
``` | ||
|
||
You can create a `Range` aggregation using the `rangeAggregation` method this way: | ||
```scala | ||
val aggregation: RangeAggregation = rangeAggregation(name = "rangeAggregation", field = "testField", range = SingleRange.to(23.9)) | ||
``` | ||
|
||
You can create a [type-safe](https://lambdaworks.github.io/zio-elasticsearch/overview/overview_zio_prelude_schema) `Range` aggregation using the `rangeAggregation` method this way: | ||
```scala | ||
// Document.intField must be number value, because of Min aggregation | ||
val aggregation: RangeAggregation = rangeAggregation(name = "rangeAggregation", field = Document.intField, range = SingleRange.to(23.9)) | ||
``` | ||
|
||
You can find more information about `Range` aggregation [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-aggregations-bucket-range-aggregation.html). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,29 @@ final case class PercentileRanksAggregationResult private[elasticsearch] (values | |
final case class PercentilesAggregationResult private[elasticsearch] (values: Map[String, Double]) | ||
extends AggregationResult | ||
|
||
private[elasticsearch] sealed trait RangeAggregationResult extends AggregationResult | ||
|
||
private[elasticsearch] final case class RegularRangeAggregationBucketResult( | ||
key: String, | ||
to: Option[Double], | ||
from: Option[Double], | ||
docCount: Int | ||
) | ||
|
||
private[elasticsearch] final case class KeyedRangeAggregationBucketResult( | ||
to: Option[Double], | ||
from: Option[Double], | ||
docCount: Int | ||
) | ||
|
||
private[elasticsearch] final case class RegularRangeAggregationResult( | ||
buckets: Chunk[RegularRangeAggregationBucketResult] | ||
) extends RangeAggregationResult | ||
|
||
private[elasticsearch] final case class KeyedRangeAggregationResult( | ||
buckets: Map[String, KeyedRangeAggregationBucketResult] | ||
) extends RangeAggregationResult | ||
|
||
Comment on lines
+68
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep this alphabetically sorted. |
||
final case class StatsAggregationResult private[elasticsearch] ( | ||
count: Int, | ||
min: Double, | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this named
SingleRange
? Why notRange
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot have two case classes with the same name inside the same package. I don't like the SingleRange name either, but I can't think of a better approach right now.