|
74 | 74 | - match: { _source.ip_location.asn: 57344 } |
75 | 75 | - match: { _source.ip_location.ip: "5.104.168.0" } |
76 | 76 | - match: { _source.ip_location.network: "5.104.168.0/23" } |
| 77 | + |
| 78 | +--- |
| 79 | +"Test ip_location processor with flexible field access mode": |
| 80 | + - skip: |
| 81 | + features: [ "flexible_field_access_pattern" ] |
| 82 | + reason: "Flexible field access pattern support required" |
| 83 | + - do: |
| 84 | + ingest.put_pipeline: |
| 85 | + id: "my_pipeline_flexible" |
| 86 | + body: > |
| 87 | + { |
| 88 | + "description": "Test flexible field access mode with dotted target field", |
| 89 | + "field_access_pattern": "flexible", |
| 90 | + "processors": [ |
| 91 | + { |
| 92 | + "ip_location" : { |
| 93 | + "field" : "ip", |
| 94 | + "target_field" : "geo.location_data" |
| 95 | + } |
| 96 | + } |
| 97 | + ] |
| 98 | + } |
| 99 | + - match: { acknowledged: true } |
| 100 | + - do: |
| 101 | + index: |
| 102 | + index: test |
| 103 | + id: "1" |
| 104 | + pipeline: "my_pipeline_flexible" |
| 105 | + body: {ip: "89.160.20.128"} |
| 106 | + - do: |
| 107 | + get: |
| 108 | + index: test |
| 109 | + id: "1" |
| 110 | + - match: { _source.ip: "89.160.20.128" } |
| 111 | + # In flexible mode, fields are written as dotted keys, not nested objects |
| 112 | + - match: { _source.geo\.location_data\.city_name: "Linköping" } |
| 113 | + - match: { _source.geo\.location_data\.country_iso_code: "SE" } |
| 114 | + - match: { _source.geo\.location_data\.country_name: "Sweden" } |
| 115 | + - match: { _source.geo\.location_data\.continent_name: "Europe" } |
| 116 | + - match: { _source.geo\.location_data\.region_iso_code: "SE-E" } |
| 117 | + - match: { _source.geo\.location_data\.region_name: "Östergötland County" } |
| 118 | + # Location should remain as a composite object (geopoint) |
| 119 | + - match: { _source.geo\.location_data\.location.lon: 15.6167 } |
| 120 | + - match: { _source.geo\.location_data\.location.lat: 58.4167 } |
| 121 | + # Verify that nested object was NOT created |
| 122 | + - is_false: _source.geo |
| 123 | +--- |
| 124 | +"Test ip_location processor flexible mode with ASN database": |
| 125 | + - skip: |
| 126 | + features: [ "flexible_field_access_pattern" ] |
| 127 | + |
| 128 | + reason: "Flexible field access pattern support required" |
| 129 | + - do: |
| 130 | + ingest.put_pipeline: |
| 131 | + id: "my_pipeline_flexible_asn" |
| 132 | + body: > |
| 133 | + { |
| 134 | + "description": "Test flexible mode with ASN database", |
| 135 | + "field_access_pattern": "flexible", |
| 136 | + "processors": [ |
| 137 | + { |
| 138 | + "ip_location" : { |
| 139 | + "field" : "source_ip", |
| 140 | + "target_field" : "network.asn_info", |
| 141 | + "database_file" : "asn.mmdb" |
| 142 | + } |
| 143 | + } |
| 144 | + ] |
| 145 | + } |
| 146 | + - match: { acknowledged: true } |
| 147 | + - do: |
| 148 | + index: |
| 149 | + index: test |
| 150 | + id: "1" |
| 151 | + pipeline: "my_pipeline_flexible_asn" |
| 152 | + body: {source_ip: "5.104.168.0"} |
| 153 | + - do: |
| 154 | + get: |
| 155 | + index: test |
| 156 | + id: "1" |
| 157 | + - match: { _source.source_ip: "5.104.168.0" } |
| 158 | + # In flexible mode, ASN fields are written as dotted keys |
| 159 | + - match: { _source.network\.asn_info\.ip: "5.104.168.0" } |
| 160 | + - match: { _source.network\.asn_info\.asn: 57344 } |
| 161 | + - match: { _source.network\.asn_info\.organization_name: "Telehouse EAD" } |
| 162 | + - match: { _source.network\.asn_info\.network: "5.104.168.0/23" } |
| 163 | + # Verify that nested object was NOT created |
| 164 | + - is_false: _source.network |
| 165 | +--- |
| 166 | +"Test ip_location processor flexible mode with first_only": |
| 167 | + - skip: |
| 168 | + |
| 169 | + features: [ "flexible_field_access_pattern" ] |
| 170 | + reason: "Flexible field access pattern support required" |
| 171 | + - do: |
| 172 | + ingest.put_pipeline: |
| 173 | + id: "my_pipeline_flexible_first" |
| 174 | + body: > |
| 175 | + { |
| 176 | + "description": "Test flexible mode with array and first_only", |
| 177 | + "field_access_pattern": "flexible", |
| 178 | + "processors": [ |
| 179 | + { |
| 180 | + "ip_location" : { |
| 181 | + "field" : "ips", |
| 182 | + "target_field" : "geo.data", |
| 183 | + "first_only" : true |
| 184 | + } |
| 185 | + } |
| 186 | + ] |
| 187 | + } |
| 188 | + - match: { acknowledged: true } |
| 189 | + - do: |
| 190 | + index: |
| 191 | + index: test |
| 192 | + id: "1" |
| 193 | + pipeline: "my_pipeline_flexible_first" |
| 194 | + body: {ips: ["127.0.0.1", "89.160.20.128"]} |
| 195 | + - do: |
| 196 | + get: |
| 197 | + index: test |
| 198 | + id: "1" |
| 199 | + - match: { _source.ips.0: "127.0.0.1" } |
| 200 | + - match: { _source.ips.1: "89.160.20.128" } |
| 201 | + # Only the first valid IP should be processed |
| 202 | + - match: { _source.geo\.data\.city_name: "Linköping" } |
| 203 | + - match: { _source.geo\.data\.country_iso_code: "SE" } |
| 204 | + - match: { _source.geo\.data\.location.lon: 15.6167 } |
| 205 | + - match: { _source.geo\.data\.location.lat: 58.4167 } |
| 206 | +--- |
| 207 | +"Test ip_location processor classic mode vs flexible mode comparison": |
| 208 | + - skip: |
| 209 | + |
| 210 | + features: [ "flexible_field_access_pattern" ] |
| 211 | + reason: "Flexible field access pattern support required" |
| 212 | + - do: |
| 213 | + ingest.put_pipeline: |
| 214 | + id: "classic_pipeline" |
| 215 | + body: > |
| 216 | + { |
| 217 | + "description": "Classic mode creates nested objects", |
| 218 | + "processors": [ |
| 219 | + { |
| 220 | + "ip_location" : { |
| 221 | + "field" : "ip", |
| 222 | + "target_field" : "geo.info" |
| 223 | + } |
| 224 | + } |
| 225 | + ] |
| 226 | + } |
| 227 | + - match: { acknowledged: true } |
| 228 | + - do: |
| 229 | + ingest.put_pipeline: |
| 230 | + id: "flexible_pipeline" |
| 231 | + body: > |
| 232 | + { |
| 233 | + "description": "Flexible mode creates dotted fields", |
| 234 | + "field_access_pattern": "flexible", |
| 235 | + "processors": [ |
| 236 | + { |
| 237 | + "ip_location" : { |
| 238 | + "field" : "ip", |
| 239 | + "target_field" : "geo.info" |
| 240 | + } |
| 241 | + } |
| 242 | + ] |
| 243 | + } |
| 244 | + - match: { acknowledged: true } |
| 245 | + - do: |
| 246 | + index: |
| 247 | + index: test |
| 248 | + id: "classic" |
| 249 | + pipeline: "classic_pipeline" |
| 250 | + body: {ip: "89.160.20.128"} |
| 251 | + - do: |
| 252 | + index: |
| 253 | + index: test |
| 254 | + id: "flexible" |
| 255 | + pipeline: "flexible_pipeline" |
| 256 | + body: {ip: "89.160.20.128"} |
| 257 | + - do: |
| 258 | + get: |
| 259 | + index: test |
| 260 | + id: "classic" |
| 261 | + # Classic mode creates nested objects |
| 262 | + - match: { _source.geo.info.city_name: "Linköping" } |
| 263 | + - match: { _source.geo.info.location.lon: 15.6167 } |
| 264 | + - do: |
| 265 | + get: |
| 266 | + index: test |
| 267 | + id: "flexible" |
| 268 | + # Flexible mode creates dotted fields |
| 269 | + - match: { _source.geo\.info\.city_name: "Linköping" } |
| 270 | + - match: { _source.geo\.info\.location.lon: 15.6167 } |
| 271 | + - is_false: _source.geo |
0 commit comments