|
| 1 | +setup: |
| 2 | + - requires: |
| 3 | + test_runner_features: close_to |
| 4 | + |
| 5 | + - do: |
| 6 | + indices.create: |
| 7 | + index: test |
| 8 | + body: |
| 9 | + settings: |
| 10 | + number_of_shards: "1" |
| 11 | + mappings: |
| 12 | + properties: |
| 13 | + nested: |
| 14 | + type: nested |
| 15 | + properties: |
| 16 | + type: |
| 17 | + type: keyword |
| 18 | + value: |
| 19 | + type: integer |
| 20 | + |
| 21 | + # Type:normal has many "1" and just one "2". Type:outlier has the same amount of "1" and "2" |
| 22 | + - do: |
| 23 | + bulk: |
| 24 | + index: test |
| 25 | + refresh: true |
| 26 | + body: |
| 27 | + - '{ "index": {} }' |
| 28 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 29 | + - '{ "index": {} }' |
| 30 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 31 | + - '{ "index": {} }' |
| 32 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 33 | + - '{ "index": {} }' |
| 34 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 35 | + - '{ "index": {} }' |
| 36 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 37 | + - '{ "index": {} }' |
| 38 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 39 | + - '{ "index": {} }' |
| 40 | + - '{ "type": "normal", "value": 1, "nested": { "type": "normal", "value": 1 } }' |
| 41 | + - '{ "index": {} }' |
| 42 | + - '{ "type": "normal", "value": 2, "nested": { "type": "normal", "value": 2 } }' |
| 43 | + |
| 44 | + - '{ "index": {} }' |
| 45 | + - '{ "type": "outlier", "value": 1, "nested": { "type": "outlier", "value": 1 } }' |
| 46 | + - '{ "index": {} }' |
| 47 | + - '{ "type": "outlier", "value": 1, "nested": { "type": "outlier", "value": 1 } }' |
| 48 | + - '{ "index": {} }' |
| 49 | + - '{ "type": "outlier", "value": 1, "nested": { "type": "outlier", "value": 1 } }' |
| 50 | + - '{ "index": {} }' |
| 51 | + - '{ "type": "outlier", "value": 1, "nested": { "type": "outlier", "value": 1 } }' |
| 52 | + - '{ "index": {} }' |
| 53 | + - '{ "type": "outlier", "value": 2, "nested": { "type": "outlier", "value": 2 } }' |
| 54 | + - '{ "index": {} }' |
| 55 | + - '{ "type": "outlier", "value": 2, "nested": { "type": "outlier", "value": 2 } }' |
| 56 | + - '{ "index": {} }' |
| 57 | + - '{ "type": "outlier", "value": 2, "nested": { "type": "outlier", "value": 2 } }' |
| 58 | + - '{ "index": {} }' |
| 59 | + - '{ "type": "outlier", "value": 2, "nested": { "type": "outlier", "value": 2 } }' |
| 60 | + |
| 61 | +--- |
| 62 | +"Data checks": |
| 63 | + - do: |
| 64 | + search: |
| 65 | + rest_total_hits_as_int: true |
| 66 | + index: test |
| 67 | + - match: {hits.total: 16} |
| 68 | + |
| 69 | + - do: |
| 70 | + search: |
| 71 | + rest_total_hits_as_int: true |
| 72 | + index: test |
| 73 | + body: { |
| 74 | + "aggs": { |
| 75 | + "value_terms": { |
| 76 | + "terms": { |
| 77 | + "field": "value" |
| 78 | + } |
| 79 | + }, |
| 80 | + "nested": { |
| 81 | + "nested": { |
| 82 | + "path": "nested" |
| 83 | + }, |
| 84 | + "aggs": { |
| 85 | + "nested_value_terms": { |
| 86 | + "terms": { |
| 87 | + "field": "nested.value" |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + - match: {aggregations.value_terms.buckets.0.key: 1} |
| 96 | + - match: {aggregations.value_terms.buckets.0.doc_count: 11} |
| 97 | + - match: {aggregations.value_terms.buckets.1.key: 2} |
| 98 | + - match: {aggregations.value_terms.buckets.1.doc_count: 5} |
| 99 | + |
| 100 | + - match: {aggregations.nested.doc_count: 16} |
| 101 | + - match: {aggregations.nested.nested_value_terms.buckets.0.key: 1} |
| 102 | + - match: {aggregations.nested.nested_value_terms.buckets.0.doc_count: 11} |
| 103 | + - match: {aggregations.nested.nested_value_terms.buckets.1.key: 2} |
| 104 | + - match: {aggregations.nested.nested_value_terms.buckets.1.doc_count: 5} |
| 105 | + |
| 106 | +--- |
| 107 | +"Normal fields": |
| 108 | + - do: |
| 109 | + search: |
| 110 | + rest_total_hits_as_int: true |
| 111 | + index: test |
| 112 | + - match: {hits.total: 16} |
| 113 | + |
| 114 | + - do: |
| 115 | + search: |
| 116 | + rest_total_hits_as_int: true |
| 117 | + index: test |
| 118 | + body: { |
| 119 | + "query": { |
| 120 | + "terms": { "type": [ "outlier" ] } |
| 121 | + }, |
| 122 | + "aggs": { |
| 123 | + "significant_terms": { |
| 124 | + "significant_terms": { |
| 125 | + "field": "value" |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + - match: {aggregations.significant_terms.doc_count: 8} |
| 132 | + - match: {aggregations.significant_terms.bg_count: 16} |
| 133 | + - length: {aggregations.significant_terms.buckets: 1} |
| 134 | + - match: {aggregations.significant_terms.buckets.0.key: 2} |
| 135 | + - match: {aggregations.significant_terms.buckets.0.doc_count: 4} |
| 136 | + - match: {aggregations.significant_terms.buckets.0.bg_count: 5} |
| 137 | + - close_to: { aggregations.significant_terms.buckets.0.score: {value: 0.3, error: 0.000001 }} |
| 138 | + |
| 139 | +--- |
| 140 | +"Nested fields": |
| 141 | + - do: |
| 142 | + search: |
| 143 | + rest_total_hits_as_int: true |
| 144 | + index: test |
| 145 | + - match: {hits.total: 16} |
| 146 | + |
| 147 | + - do: |
| 148 | + search: |
| 149 | + rest_total_hits_as_int: true |
| 150 | + index: test |
| 151 | + body: { |
| 152 | + "query": { |
| 153 | + "terms": { "type": [ "outlier" ] } |
| 154 | + }, |
| 155 | + "aggs": { |
| 156 | + "nested": { |
| 157 | + "nested": { |
| 158 | + "path": "nested" |
| 159 | + }, |
| 160 | + "aggs": { |
| 161 | + "significant_terms": { |
| 162 | + "significant_terms": { |
| 163 | + "field": "nested.value" |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + - match: {aggregations.nested.significant_terms.doc_count: 8} |
| 172 | + - match: {aggregations.nested.significant_terms.bg_count: 16} |
| 173 | + - length: {aggregations.nested.significant_terms.buckets: 1} |
| 174 | + - match: {aggregations.nested.significant_terms.buckets.0.key: 2} |
| 175 | + - match: {aggregations.nested.significant_terms.buckets.0.doc_count: 4} |
| 176 | + - match: {aggregations.nested.significant_terms.buckets.0.bg_count: 5} |
| 177 | + - close_to: { aggregations.nested.significant_terms.buckets.0.score: {value: 0.3, error: 0.000001 }} |
0 commit comments