"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/100_avg_metric.yml" (29 Dec 2021, 3756 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 setup:
    2   - do:
    3       indices.create:
    4           index: test_1
    5           body:
    6             settings:
    7               number_of_replicas: 0
    8             mappings:
    9               doc:
   10                 properties:
   11                   int_field:
   12                      type : integer
   13                   double_field:
   14                      type : double
   15                   string_field:
   16                      type: keyword
   17 
   18   - do:
   19        bulk:
   20          refresh: true
   21          body:
   22            - index:
   23                _index: test_1
   24                _type:  doc
   25                _id:    1
   26            - int_field: 1
   27              double_field: 1.0
   28              string_field: foo
   29            - index:
   30                _index: test_1
   31                _type:  doc
   32                _id:    2
   33            - int_field: 51
   34              double_field: 51.0
   35              string_field: foo
   36            - index:
   37                _index: test_1
   38                _type:  doc
   39                _id:    3
   40            - int_field: 101
   41              double_field: 101.0
   42              string_field: foo
   43            - index:
   44                _index: test_1
   45                _type:  doc
   46                _id:    4
   47            - int_field: 151
   48              double_field: 151.0
   49              string_field: foo
   50 
   51 ---
   52 "Basic test":
   53 
   54   - do:
   55       search:
   56         body:
   57           aggs:
   58             the_int_avg:
   59               avg:
   60                 field: int_field
   61             the_double_avg:
   62               avg:
   63                 field: double_field
   64 
   65   - match: { hits.total: 4 }
   66   - length: { hits.hits: 4 }
   67   - match: { aggregations.the_int_avg.value: 76.0 }
   68   - match: { aggregations.the_double_avg.value: 76.0 }
   69 
   70 ---
   71 "Only aggs test":
   72 
   73   - do:
   74       search:
   75         body:
   76           size: 0
   77           aggs:
   78             the_int_avg:
   79               avg:
   80                 field: int_field
   81             the_double_avg:
   82               avg:
   83                 field: double_field
   84 
   85   - match: { hits.total: 4 }
   86   - length: { hits.hits: 0 }
   87   - match: { aggregations.the_int_avg.value: 76.0 }
   88   - match: { aggregations.the_double_avg.value: 76.0 }
   89 
   90 ---
   91 "Filtered test":
   92 
   93   - do:
   94       search:
   95         body:
   96           query:
   97             constant_score:
   98               filter:
   99                 range:
  100                   int_field:
  101                     gte: 50
  102           aggs:
  103             the_int_avg:
  104               avg:
  105                 field: int_field
  106             the_double_avg:
  107               avg:
  108                 field: double_field
  109 
  110   - match: { hits.total: 3 }
  111   - length: { hits.hits: 3 }
  112   - match: { aggregations.the_int_avg.value: 101.0 }
  113   - match: { aggregations.the_double_avg.value: 101.0 }
  114 
  115 
  116 ---
  117 "Missing field with missing param":
  118 
  119   - do:
  120       search:
  121         body:
  122           aggs:
  123             the_missing_avg:
  124               avg:
  125                 field: foo
  126                 missing: 1
  127 
  128   - match: { hits.total: 4 }
  129   - length: { hits.hits: 4 }
  130   - match: { aggregations.the_missing_avg.value: 1 }
  131 
  132 ---
  133 "Missing field without missing param":
  134 
  135   - do:
  136       search:
  137         body:
  138           aggs:
  139             the_missing_avg:
  140               avg:
  141                 field: foo
  142 
  143   - match: { hits.total: 4 }
  144   - length: { hits.hits: 4 }
  145   - is_false: aggregations.the_missing_avg.value
  146 
  147 ---
  148 "Metadata test":
  149 
  150   - do:
  151       search:
  152         body:
  153           aggs:
  154             the_int_avg:
  155               meta:
  156                 foo: bar
  157               avg:
  158                 field: int_field
  159 
  160   - match: { hits.total: 4 }
  161   - length: { hits.hits: 4 }
  162   - match: { aggregations.the_int_avg.value: 76.0 }
  163   - match: { aggregations.the_int_avg.meta.foo: "bar" }
  164 
  165 ---
  166 "Aggregating wrong datatype test":
  167 
  168   - do:
  169       catch: bad_request
  170       search:
  171         body:
  172           aggs:
  173             the_string_avg:
  174               avg:
  175                 field: string_field
  176