Skip to content

Commit 7390c5d

Browse files
committed
fix bucket selector agregation script
1 parent 1fb2b5f commit 7390c5d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

es6/sql-bridge/src/main/scala/app/softnetwork/elastic/sql/bridge/ElasticAggregation.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ object ElasticAggregation {
206206
aggregationsDirection: Map[String, SortOrder],
207207
having: Option[Criteria]
208208
): Option[TermsAggregation] = {
209-
Console.println(bucketsDirection)
210209
buckets.reverse.foldLeft(Option.empty[TermsAggregation]) { (current, bucket) =>
211210
val agg = {
212211
bucketsDirection.get(bucket.identifier.identifierName) match {
@@ -241,7 +240,11 @@ object ElasticAggregation {
241240
val bucketsPath = extractBucketsPath(criteria)
242241

243242
val bucketSelector =
244-
bucketSelectorAggregation("having_filter", Script(script), bucketsPath)
243+
bucketSelectorAggregation(
244+
"having_filter",
245+
Script(script.replaceAll("1 == 1 &&", "").replaceAll("&& 1 == 1", "").trim),
246+
bucketsPath
247+
)
245248

246249
withAggregationOrders.copy(subaggs = aggregations :+ bucketSelector)
247250

sql/bridge/src/main/scala/app/softnetwork/elastic/sql/bridge/ElasticAggregation.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ object ElasticAggregation {
238238
val bucketsPath = extractBucketsPath(criteria)
239239

240240
val bucketSelector =
241-
bucketSelectorAggregation("having_filter", Script(script), bucketsPath)
241+
bucketSelectorAggregation(
242+
"having_filter",
243+
Script(script.replaceAll("1 == 1 &&", "").replaceAll("&& 1 == 1", "").trim),
244+
bucketsPath
245+
)
242246

243247
withAggregationOrders.copy(subaggs = aggregations :+ bucketSelector)
244248

0 commit comments

Comments
 (0)