Bucket Script Aggregating on fields that contain a period


(Tadgh) #1

I am performing a percentiles aggregate over data. I also want to perform a bucket_script aggregation, based on the results of the percentiles (defining interquartile range). I am unable to query the percentile values, as I seem to be unable to query over fields that contain a period. Here is my query:

{
  "size": 0,
        "aggs": {
          "base_agg": {
            "terms": {"field": "action.keyword"},
            "aggs": {
              "score_outlier": {
                "percentiles": {
                  "field": "actionParameters.score_numeric"
                 }
              },
              "iqr": {
                "bucket_script": {
                  "buckets_path": {
                    "q1": "score_outlier.values.25.0",
                    "q3": "score_outlier.values.75.0"
                  },
                  "script": "params.q3 - params.q1"
                }
              }
            }
          }
        }
}

The results from the percentiles aggregate looks as expected:

 "score_outlier": {
         "values" : {
            "1.0": 5.0,
            "5.0": 25.0,
            "25.0": 165.0,
            "50.0": 445.0,
            "75.0": 725.0,
            "95.0": 945.0,
            "99.0": 985.0
         }
      }

I've tried escaping multiple ways, but no dice:
No aggregation found for path [score_outlier.values.25.0]


[BUG?] Escaping periods in vega-lite calculate transform
(Frederico Galvão) #2

Make sure to read the docs on the buckets_path sintax, and see if that clarifies it for you:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html#buckets-path-syntax
(remember to change the version of the docs from master to the one you're using)


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.