2

I made some elasticsearch query like below and it works well.

  "aggregations" : {
    "agg_sum" : {
      "sum" : {
        "field" : "cnt"
      }
    },
    "bucket_filter": {
        "bucket_selector": {
            "buckets_path": {
              "totalSales": "agg_sum"
            },
            "script": "totalSales >= 10"
        }
    }
  }

It needed to be converted as java api query, but don't know how to convert "buckets_filter". any idea of this?

1 Answer 1

5

BucketSelector in java api would be like this:

Map<String, String> bucketsPathsMap = new HashMap<>();
        bucketsPathsMap.put("ags", "agg_sum");
        Script script = new Script("params.ags > 10");

   BucketSelectorPipelineAggregationBuilder bs =
                PipelineAggregatorBuilders.bucketSelector("bucket_filter", bucketsPathsMap, script);
AggregationBuilders.subAggregation(bs);

this is probably too late, just for sake of same problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.