N1ql根据字段值从集合中获取数据

时间:2016-09-13 13:40:38

标签: n1ql

我有一份文件如下

{
    "GMParcelStatus": {
    "storeNumber": 5678,
    "GMVehicleTrips": {
    "GMVehicleTrip": [
    {
    "GMVehicleTripId": "1000101",
    "MultiChannelOrders": {
    "MultiChannelOrder": [
    {
    "multiChannelOrderID": "4BQGBNJ3U",
    "multichannelParcels": [
    {
    "multiChannelParcelStatus": "LOADING_MISSING",
    "UPI": "00000008101058629797"
    },
    {
    "multiChannelParcelStatus": "OUTFORDELIVERY",
    "UPI": "00000008101058684938"
    }
    ]
    },
    {
    "multiChannelOrderID": "4BQGUNY56W",
    "multichannelParcels": [
    {
    "multiChannelParcelStatus": "DELIVERED",
    "UPI": "00000008101058629793"
    },
    {
    "multiChannelParcelStatus": "DELIVERED",
    "UPI": "00000008101058684932"
    }
    ]
    }
    ]
    }
    }
    ]
    }
    },
    "_class": "com.tesco.bean.MultiChannelParcelRequestVO"
    }

我想根据storeNumber和GMVehicleTripId获取我的存储桶数据中的所有文档。     我有4个类似于上面的文件,有不同的GMVehicleTripId。

我写了如下的N1ql查询选择d。*来自交货d JOIN Delivery.GMParcelStatus.GMVehicleTrips.GMVehicleTrip [0] b     在键上(d).id其中b.GMVehicleTripId在['1000101']

but i don't want to do this GMVehicleTrip[0].

please get me the right way to do.

Thanks,
Vinay J

1 个答案:

答案 0 :(得分:1)

SELECT d.* FROM  Delivery d JOIN Delivery b ON KEYS meta(d).id 
WHERE ANY v IN b.GMParcelStatus.GMVehicleTrips.GMVehicleTrip SATISFIES v.GMVehicleTripId IN ['1000101'] END;