Bonjour !
Actuellement, j'indexe des documents de la sorte::
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "nmb2b-2017.03.02",
"_type": "FlightListByAerodromeReply",
"_id": "AVqOakryqXFr_vbJPqLG",
"_score": 1,
"_source": {
"@timestamp": "2017-03-02T09:46:53.902Z",
"port": 18523,
"@version": "1",
"host": "192.168.10.195",
"parsed": {
"xmlns:S": "http://schemas.xmlsoap.org/soap/envelope/",
"Body": {
"FlightListByAerodromeReply": {
"xmlns:common": "eurocontrol/cfmu/b2b/CommonServices",
"requestReceptionTime": "2017-03-02 09:58:55",
"data": {
"effectiveTrafficWindow": {
"wef": "2017-03-02 08:00",
"unt": "2017-03-02 20:00"
},
"flights": [
{
"flight": {
"flightId": {
"keys": {
"aircraftId": "BEL32C",
"aerodromeOfDestination": "EBBR",
"estimatedOffBlockTime": "2017-03-02 07:45",
"airFiled": "false",
"nonICAOAerodromeOfDestination": "false",
"nonICAOAerodromeOfDeparture": "false",
"aerodromeOfDeparture": "LFPG"
},
"id": "AT02676815"
}
}
},
{
"flight": {
"flightId": {
"keys": {
"aircraftId": "AFR1033",
"aerodromeOfDestination": "LFPG",
"estimatedOffBlockTime": "2017-03-02 04:30",
"airFiled": "false",
"nonICAOAerodromeOfDestination": "false",
"nonICAOAerodromeOfDeparture": "false",
"aerodromeOfDeparture": "LGAV"
},
"id": "AT02680179"
}
}
}
},
"xmlns:flight": "eurocontrol/cfmu/b2b/FlightServices",
"requestId": "B2B_CUR:2419467",
"xmlns:flow": "eurocontrol/cfmu/b2b/FlowServices",
"xmlns:airspace": "eurocontrol/cfmu/b2b/AirspaceServices",
"sendTime": "2017-03-02 09:59:42",
"status": "OK"
}
}
},
"type": "FlightListByAerodromeReply",
"tags": []
}
}
]
}
}
Comme vous pouvez le constater, je dispose d'un objet JSON 'flights' de type 'Array' qui peut contenir N 'flight':
"flights": [
{
"flight": {
"flightId": {
"keys": {
"aircraftId": "BEL32C",
"aerodromeOfDestination": "EBBR",
"estimatedOffBlockTime": "2017-03-02 07:45",
"airFiled": "false",
"nonICAOAerodromeOfDestination": "false",
"nonICAOAerodromeOfDeparture": "false",
"aerodromeOfDeparture": "LFPG"
},
"id": "AT02676815"
}
}
},
Or, dans certains cas, ces 'flight' peuvent ne pas contenir de champs 'id':
"flights": [
{
"flight": {
"flightId": {
"keys": {
"aircraftId": "FRA34Z",
"aerodromeOfDestination": "EBBR",
"estimatedOffBlockTime": "2017-03-02 07:45",
"airFiled": "false",
"nonICAOAerodromeOfDestination": "false",
"nonICAOAerodromeOfDeparture": "false",
"aerodromeOfDeparture": "LFPG"
}
}
}
},
Je souhaiterai donc effectuer une requête ES qui me permettrait de retourner tous les 'flight' qui contiennent bien un champs 'id'.
Etant novice dans les requêtes ES, pensez-vous que cela est possible ? Si oui comment faire ?
Merci d'avance !
J'en profite pour mettre le mapping:
{
"template": "nmb2b-*",
"settings": { "number_of_shards": 5 },
"mappings": {
"FlightListByAerodromeReply": {
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string"
},
"host": {
"type": "string"
},
"parsed": {
"properties": {
"Body": {
"properties": {
"FlightListByAerodromeReply": {
"properties": {
"data": {
"properties": {
"effectiveTrafficWindow": {
"properties": {
"unt": {
"type": "string"
},
"wef": {
"type": "string"
}
}
},
"flights": {
"properties": {
"flight": {
"properties": {
"flightId": {
"properties": {
"id": {
"type": "string"
},
"keys": {
"properties": {
"aerodromeOfDeparture": {
"type": "string"
},
"aerodromeOfDestination": {
"type": "string"
},
"airFiled": {
"type": "string"
},
"aircraftId": {
"type": "string"
},
"estimatedOffBlockTime": {
"type": "string"
},
"nonICAOAerodromeOfDeparture": {
"type": "string"
},
"nonICAOAerodromeOfDestination": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
"requestId": {
"type": "string"
},
"requestReceptionTime": {
"type": "string"
},
"sendTime": {
"type": "string"
},
"status": {
"type": "string"
},
"xmlns:airspace": {
"type": "string"
},
"xmlns:common": {
"type": "string"
},
"xmlns:flight": {
"type": "string"
},
"xmlns:flow": {
"type": "string"
}
}
}
}
},
"xmlns:S": {
"type": "string"
}
}
},
"port": {
"type": "long"
},
"query": {
"properties": {
"query_string": {
"properties": {
"query": {
"type": "string"
}
}
}
}
},
"type": {
"type": "string"
}
}
}
}
}