All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rest-api-spec.test.search.aggregation.180_percentiles_tdigest_metric.yml Maven / Gradle / Ivy

The newest version!
setup:
  - do:
      indices.create:
          index: test_1
          body:
            settings:
              number_of_replicas: 0
            mappings:
              properties:
                int_field:
                   type : integer
                double_field:
                   type : double
                string_field:
                   type: keyword

  - do:
       bulk:
         refresh: true
         body:
           - index:
               _index: test_1
               _id:    1
           - int_field: 1
             double_field: 1.0
             string_field: foo
           - index:
               _index: test_1
               _id:    2
           - int_field: 51
             double_field: 51.0
             string_field: foo
           - index:
               _index: test_1
               _id:    3
           - int_field: 101
             double_field: 101.0
             string_field: foo
           - index:
               _index: test_1
               _id:    4
           - int_field: 151
             double_field: 151.0
             string_field: foo

---
"Basic test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
            percentiles_double:
              percentiles:
                field: double_field

  - match:  { hits.total: 4 }
  - length: { hits.hits: 4 }

  - match:  { aggregations.percentiles_int.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_int.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_int.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_int.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_int.values.99\.0: 151.0 }

  - match:  { aggregations.percentiles_double.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_double.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_double.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_double.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_double.values.99\.0: 151.0 }

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                tdigest:
                  compression: 200
            percentiles_double:
              percentiles:
                field: double_field
                tdigest:
                  compression: 200


  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }

  - match:  { aggregations.percentiles_int.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_int.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_int.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_int.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_int.values.99\.0: 151.0 }

  - match:  { aggregations.percentiles_double.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_double.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_double.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_double.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_double.values.99\.0: 151.0 }


---
"Only aggs test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
            percentiles_double:
              percentiles:
                field: double_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 0 }

  - match:  { aggregations.percentiles_int.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_int.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_int.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_int.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_int.values.99\.0: 151.0 }

  - match:  { aggregations.percentiles_double.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_double.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_double.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_double.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_double.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_double.values.99\.0: 151.0 }



---
"Filtered test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            constant_score:
              filter:
                range:
                  int_field:
                    gte: 50
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
            percentiles_double:
              percentiles:
                field: double_field

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }

  - match:  { aggregations.percentiles_int.values.1\.0: 51.0 }
  - match:  { aggregations.percentiles_int.values.5\.0: 51.0 }
  - match:  { aggregations.percentiles_int.values.25\.0: 63.5 }
  - match:  { aggregations.percentiles_int.values.50\.0: 101.0 }
  - match:  { aggregations.percentiles_int.values.75\.0: 138.5 }
  - match:  { aggregations.percentiles_int.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_int.values.99\.0: 151.0 }

  - match:  { aggregations.percentiles_double.values.1\.0: 51.0 }
  - match:  { aggregations.percentiles_double.values.5\.0: 51.0 }
  - match:  { aggregations.percentiles_double.values.25\.0: 63.5 }
  - match:  { aggregations.percentiles_double.values.50\.0: 101.0 }
  - match:  { aggregations.percentiles_double.values.75\.0: 138.5 }
  - match:  { aggregations.percentiles_double.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_double.values.99\.0: 151.0 }

---
"Missing field with missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_missing:
              percentiles:
                field: missing_field
                missing: 1.0

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }

  - match:  { aggregations.percentiles_missing.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.25\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.50\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.75\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.95\.0: 1.0 }
  - match:  { aggregations.percentiles_missing.values.99\.0: 1.0 }

---
"Missing field without missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_missing:
              percentiles:
                field: missing_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - is_false: aggregations.percentiles_missing.value

---
"Metadata test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              meta:
                foo: bar
              percentiles:
                field: int_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - match: { aggregations.percentiles_int.meta.foo: "bar" }


  - match:  { aggregations.percentiles_int.values.1\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.5\.0: 1.0 }
  - match:  { aggregations.percentiles_int.values.25\.0: 26.0 }
  - match:  { aggregations.percentiles_int.values.50\.0: 76.0 }
  - match:  { aggregations.percentiles_int.values.75\.0: 126.0 }
  - match:  { aggregations.percentiles_int.values.95\.0: 151.0 }
  - match:  { aggregations.percentiles_int.values.99\.0: 151.0 }

---
"Invalid params test":

  - do:
      catch: /\[compression\] must be greater than or equal to 0. Found \[-1.0\]/
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                tdigest:
                  compression: -1

  - do:
      catch: bad_request
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                percents: []

  - do:
      catch: bad_request
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                percents: null

  - do:
      catch: bad_request
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                percents: ["foo"]

  - do:
      catch: bad_request
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_string:
              percentiles:
                field: string_field

---
"Explicit Percents test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                percents: [5.0, 25.0, 50.0]
            percentiles_double:
              percentiles:
                field: double_field
                percents: [5.0, 25.0, 50.0]


  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }

  - match: { aggregations.percentiles_int.values.5\.0: 1.0 }
  - match: { aggregations.percentiles_int.values.25\.0: 26.0 }
  - match: { aggregations.percentiles_int.values.50\.0: 76.0 }

  - match: { aggregations.percentiles_double.values.5\.0: 1.0 }
  - match: { aggregations.percentiles_double.values.25\.0: 26.0 }
  - match: { aggregations.percentiles_double.values.50\.0: 76.0 }

---
"Non-keyed test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            percentiles_int:
              percentiles:
                field: int_field
                percents: [5.0, 25.0, 50.0]
                keyed: false


  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }

  - match:  { aggregations.percentiles_int.values.0.key:  5.0 }
  - match:  { aggregations.percentiles_int.values.0.value:  1.0 }
  - match:  { aggregations.percentiles_int.values.1.key:  25.0 }
  - match:  { aggregations.percentiles_int.values.1.value:  26.0 }
  - match:  { aggregations.percentiles_int.values.2.key:  50.0 }
  - match:  { aggregations.percentiles_int.values.2.value:  76.0 }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy