|
81 | 81 | - match: { "hits.hits.0._source.@timestamp": "2021-04-28T01:00:00.000Z" } |
82 | 82 | - match: { hits.hits.0._source.department: "compsci" } |
83 | 83 | - match: { hits.hits.0._source.courses: [ { "name": "Object Oriented Programming", "credits": 3 }, { "name": "Theory of Computation", "credits": 4, } ] } |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +"TSDB index with multi-level nested fields": |
| 88 | + - do: |
| 89 | + indices.create: |
| 90 | + index: test |
| 91 | + body: |
| 92 | + settings: |
| 93 | + index: |
| 94 | + mode: time_series |
| 95 | + number_of_replicas: 1 |
| 96 | + number_of_shards: 1 |
| 97 | + routing_path: [department] |
| 98 | + time_series: |
| 99 | + start_time: 2021-04-28T00:00:00Z |
| 100 | + end_time: 2021-04-29T00:00:00Z |
| 101 | + mappings: |
| 102 | + properties: |
| 103 | + "@timestamp": |
| 104 | + type: date |
| 105 | + department: |
| 106 | + type: keyword |
| 107 | + time_series_dimension: true |
| 108 | + staff: |
| 109 | + type: integer |
| 110 | + courses: |
| 111 | + type: nested |
| 112 | + properties: |
| 113 | + name: |
| 114 | + type: keyword |
| 115 | + credits: |
| 116 | + type: integer |
| 117 | + students: |
| 118 | + type: nested |
| 119 | + properties: |
| 120 | + name: |
| 121 | + type: text |
| 122 | + major: |
| 123 | + type: keyword |
| 124 | + |
| 125 | + - do: |
| 126 | + index: |
| 127 | + index: test |
| 128 | + body: |
| 129 | + "@timestamp": "2021-04-28T01:00:00Z" |
| 130 | + department: "compsci" |
| 131 | + staff: 12 |
| 132 | + courses: |
| 133 | + - name: "Object Oriented Programming" |
| 134 | + credits: 3 |
| 135 | + students: |
| 136 | + - name: "Kimora Tanner" |
| 137 | + major: "Computer Science" |
| 138 | + - name: "Bruno Garrett" |
| 139 | + major: "Software Engineering" |
| 140 | + - name: "Theory of Computation" |
| 141 | + credits: 4 |
| 142 | + students: |
| 143 | + - name: "Elliott Booker" |
| 144 | + major: "Computer Engineering" |
| 145 | + - name: "Kimora Tanner" |
| 146 | + major: "Software Engineering" |
| 147 | + |
| 148 | + - do: |
| 149 | + index: |
| 150 | + index: test |
| 151 | + body: |
| 152 | + "@timestamp": "2021-04-28T02:00:00Z" |
| 153 | + department: "math" |
| 154 | + staff: 20 |
| 155 | + courses: |
| 156 | + - name: "Precalculus" |
| 157 | + credits: 4 |
| 158 | + students: |
| 159 | + - name: "Elliott Ayers" |
| 160 | + major: "Software Engineering" |
| 161 | + - name: "Sylvie Howe" |
| 162 | + major: "Computer Engineering" |
| 163 | + - name: "Linear Algebra" |
| 164 | + credits: 3 |
| 165 | + students: |
| 166 | + - name: "Kimora Tanner" |
| 167 | + major: "Computer Science" |
| 168 | + - name: "Bruno Garett" |
| 169 | + major: "Software Engineering" |
| 170 | + - name: "Amelia Booker" |
| 171 | + major: "Psychology" |
| 172 | + |
| 173 | + - do: |
| 174 | + index: |
| 175 | + index: test |
| 176 | + body: |
| 177 | + "@timestamp": "2021-04-28T03:00:00Z" |
| 178 | + department: "compsci" |
| 179 | + staff: 12 |
| 180 | + courses: |
| 181 | + - name: "Object Oriented Programming" |
| 182 | + credits: 3 |
| 183 | + students: |
| 184 | + - name: "Kimora Tanner" |
| 185 | + major: "Computer Science" |
| 186 | + - name: "Bruno Garrett" |
| 187 | + major: "Software Engineering" |
| 188 | + - name: "Elliott Booker" |
| 189 | + major: "Computer Engineering" |
| 190 | + - name: "Theory of Computation" |
| 191 | + credits: 4 |
| 192 | + students: |
| 193 | + - name: "Kimora Tanner" |
| 194 | + major: "Software Engineering" |
| 195 | + - name: "Elliott Ayers" |
| 196 | + major: "Software Engineering" |
| 197 | + - name: "Apollo Pittman" |
| 198 | + major: "Computer Engineering" |
| 199 | + |
| 200 | + - do: |
| 201 | + indices.refresh: |
| 202 | + index: [ test ] |
| 203 | + |
| 204 | + - do: |
| 205 | + search: |
| 206 | + index: test |
| 207 | + body: |
| 208 | + query: |
| 209 | + nested: |
| 210 | + path: "courses" |
| 211 | + query: |
| 212 | + bool: |
| 213 | + must: |
| 214 | + - nested: |
| 215 | + path: "courses.students" |
| 216 | + query: |
| 217 | + bool: |
| 218 | + must: |
| 219 | + - match: |
| 220 | + courses.students.name: "Elliott" |
| 221 | + - term: |
| 222 | + courses.students.major: "Computer Engineering" |
| 223 | + - term: |
| 224 | + courses.name: "Theory of Computation" |
| 225 | + |
| 226 | + - match: { hits.total.value: 1 } |
| 227 | + - match: { hits.hits.0._source.department: "compsci" } |
| 228 | + - match: { "hits.hits.0._source.@timestamp": "2021-04-28T01:00:00.000Z" } |
0 commit comments