-
Notifications
You must be signed in to change notification settings - Fork 17
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
(dsl): Support Extended stats
aggregation
#363
(dsl): Support Extended stats
aggregation
#363
Conversation
|
||
If you want to add aggregation (on the same level), you can use `withAgg` method: | ||
```scala | ||
val multipleAggregations: MultipleAggregations = extendedStatsAggregation(name = "extendedStatsAggregation", field = Document.intField).withAgg(extendedStatsAggregation(name = "extendedStatsAggregation2", field = Document.doubleField)) |
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.
val multipleAggregations: MultipleAggregations = extendedStatsAggregation(name = "extendedStatsAggregation", field = Document.intField).withAgg(extendedStatsAggregation(name = "extendedStatsAggregation2", field = Document.doubleField)) | |
val multipleAggregations: MultipleAggregations = extendedStatsAggregation(name = "extendedStatsAggregation1", field = Document.intField).withAgg(extendedStatsAggregation(name = "extendedStatsAggregation2", field = Document.doubleField)) |
|
||
/** | ||
* Sets the `sigma` parameter for the [[zio.elasticsearch.aggregation.ExtendedStatsAggregation]]. The`sigma` parameter | ||
* controls how many standard deviations plus/minus from the mean should std_deviation_bounds object display |
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.
* controls how many standard deviations plus/minus from the mean should std_deviation_bounds object display | |
* controls how many standard deviations plus/minus from the mean should std_deviation_bounds object display. |
* @param value | ||
* the value to use for sigma parameter | ||
* @return | ||
* an instance of the [[zio.elasticsearch.aggregation.ElasticAggregation]] enriched with the `sigma` parameter. |
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.
Maybe put reference for this aggregation instead of global ElasticAggregation
.
@@ -75,6 +105,38 @@ private[elasticsearch] object CardinalityAggregationResponse { | |||
DeriveJsonDecoder.gen[CardinalityAggregationResponse] | |||
} | |||
|
|||
case class StdDeviationBounds private[elasticsearch] ( |
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.
case class StdDeviationBounds private[elasticsearch] ( | |
private[elasticsearch] case class StdDeviationBounds private[elasticsearch] ( |
implicit val boundsDecoder: JsonDecoder[StdDeviationBounds] = | ||
DeriveJsonDecoder.gen[StdDeviationBounds] |
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.
Put this in separate object.
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.
And rename it to decoder
.
lower_sampling: Double | ||
) | ||
|
||
private[elasticsearch] final case class ExtendedStatsAggregationResponse( |
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.
Please use Camel case. You can use this @jsonField("...")
for specify name of json field.
@@ -17,6 +17,7 @@ | |||
package zio.elasticsearch.result | |||
|
|||
import zio.Chunk | |||
import zio.elasticsearch.executor.response.StdDeviationBounds |
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.
Create StdDeviationBoundsResult
with same params, and map StdDeviationBounds
to this new class. We are doing this duplication of code in the favour of privacy of the response
layer (we don't want users to know about this layer).
@@ -104,6 +104,48 @@ object HttpExecutorSpec extends IntegrationSpec { | |||
Executor.execute(ElasticRequest.createIndex(firstSearchIndex)), | |||
Executor.execute(ElasticRequest.deleteIndex(firstSearchIndex)).orDie | |||
), | |||
test("aggregate using extended stats aggregation ttt") { |
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.
test("aggregate using extended stats aggregation ttt") { | |
test("aggregate using extended stats aggregation") { |
2a1a584
to
0049424
Compare
ExtendedStatsAggregationResult( | ||
count, | ||
min, | ||
max, | ||
avg, | ||
sum, | ||
sumOfSquares, | ||
variance, | ||
variancePopulation, | ||
varianceSampling, | ||
stdDeviation, | ||
stdDeviationPopulation, | ||
stdDeviationSampling, | ||
StdDeviationBoundsResult( | ||
stdDeviationBoundsResponse.upper, | ||
stdDeviationBoundsResponse.lower, | ||
stdDeviationBoundsResponse.upperPopulation, | ||
stdDeviationBoundsResponse.lowerPopulation, | ||
stdDeviationBoundsResponse.upperSampling, | ||
stdDeviationBoundsResponse.lowerSampling | ||
) |
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.
Name paramters since there are a lot of them.
Part of #118