-
Notifications
You must be signed in to change notification settings - Fork 18
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 Weight Avg
aggregation
#358
(dsl): Support Weight Avg
aggregation
#358
Conversation
|
||
If you want to add aggregation (on the same level), you can use `withAgg` method: | ||
```scala | ||
val multipleAggregations: MultipleAggregations = weightedAvgAggregation(name = "weightedAvgAggregation", valueField = Document.intField, weightField = Document.doubleField).withAgg(weightedAvgAggregation(name = "weightedAvgAggregation", valueField = Document.doubleField, weightField = Document.intField)) |
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.
Can you give them different names?
|
||
If you want to change the `valueMissing`, you can use `valueMissing` method: | ||
```scala | ||
val aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).valueMissing(10.0) |
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 aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).valueMissing(10.0) | |
val aggregationWithValueMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).valueMissing(10.0) |
|
||
If you want to change the `weightMissing`, you can use `weightMissing` method: | ||
```scala | ||
val aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(5.0) |
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 aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(5.0) | |
val aggregationWithWeightMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(5.0) |
|
||
If you want to change the `weightMissing` and `valueMissing`, you can use `weightMissing` and `valueMissing` methods: | ||
```scala | ||
val aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(10.0).valueMissing(5.0) |
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 aggregationWithMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(10.0).valueMissing(5.0) | |
val aggregationWithValueAndWeightMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(10.0).valueMissing(5.0) |
* @param valueField | ||
* the type-safe field for value for which weighted avg aggregation will be executed | ||
* @param weightField | ||
* the type-safe field for weight for which weighted avg aggregation will be executed |
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 something like this:
* the type-safe field for weight for which weighted avg aggregation will be executed | |
* the type-safe field that represents weight for which weighted avg aggregation will be executed |
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.
Something like this for valueField
also.
self.copy(weightMissing = Some(value)) | ||
|
||
private[elasticsearch] def toJson: Json = { | ||
|
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.
Omit empty line.
))) | ||
) | ||
) | ||
|
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.
Omit empty line.
case str if str.contains("weighted_avg#") => | ||
WeightedAvgAggregationResponse.decoder.decodeJson(data.toString).map(field.split("#")(1) -> _) |
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 first and remove && !str.contains("weighted_avg#")
from the first case.
weightedAvgAggregation("aggregation", TestDocument.stringField, TestDocument.intField).valueMissing(2.0) | ||
val aggregationWithWeightMissing = | ||
weightedAvgAggregation("aggregation", TestDocument.stringField, TestDocument.intField).weightMissing(3.0) | ||
val aggregationWithBothMissing = weightedAvgAggregation( |
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 aggregationWithBothMissing = weightedAvgAggregation( | |
val aggregationWithValueAndWeightMissing = weightedAvgAggregation( |
weightedAvgAggregation("aggregation", TestDocument.stringField, TestDocument.intField).valueMissing(2.0) | ||
val aggregationWithWeightMissing = | ||
weightedAvgAggregation("aggregation", TestDocument.stringField, TestDocument.intField).weightMissing(3.0) | ||
val aggregationWithBothMissing = weightedAvgAggregation( |
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.
Same.
384cbac
to
4237565
Compare
Weight Avg
aggregation
|
||
If you want to add aggregation (on the same level), you can use `withAgg` method: | ||
```scala | ||
val multipleAggregations: MultipleAggregations = weightedAvgAggregation(name = "weightedAvgAggregation", valueField = Document.intField, weightField = Document.doubleField).withAgg(weightedAvgAggregation(name = "weightedAvgAggregation2", valueField = Document.doubleField, weightField = Document.intField)) |
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 = weightedAvgAggregation(name = "weightedAvgAggregation", valueField = Document.intField, weightField = Document.doubleField).withAgg(weightedAvgAggregation(name = "weightedAvgAggregation2", valueField = Document.doubleField, weightField = Document.intField)) | |
val multipleAggregations: MultipleAggregations = weightedAvgAggregation(name = "weightedAvgAggregation1", valueField = Document.intField, weightField = Document.doubleField).withAgg(weightedAvgAggregation(name = "weightedAvgAggregation2", valueField = Document.doubleField, weightField = Document.intField)) |
|
||
If you want to change the `weightMissing` and `valueMissing`, you can use `weightMissing` and `valueMissing` methods: | ||
```scala | ||
val aggregationWithValueAndWeightMissing: WeightedAvgAggregation = weightedAvgAggregation(name = "weightedAvgAggregation", field = Document.intField).weightMissing(10.0).valueMissing(5.0) |
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 valueMissing
first.
8c2d3d2
to
c76e95f
Compare
Part of #118