Amazon web services DynamoDB查询,按数组包含键条件和筛选表达式

Amazon web services DynamoDB查询,按数组包含键条件和筛选表达式,amazon-web-services,amazon-dynamodb,aws-sdk,dynamodb-queries,aws-sdk-nodejs,Amazon Web Services,Amazon Dynamodb,Aws Sdk,Dynamodb Queries,Aws Sdk Nodejs,我想用键条件查询DDB GSI,并使用contains函数对返回的结果应用过滤器 DDB表中的数据: { "lookupType": "PRODUCT_GROUP", "name": "Spring framework study set", "structureJson": { "productIds": [ "FBCUPOQsrp", "Y4LDaiViLY", "J6N3UWq9CK" ] }, "ownerId":

我想用键条件查询DDB GSI,并使用
contains
函数对返回的结果应用过滤器

DDB表中的数据:

{
  "lookupType": "PRODUCT_GROUP",
  "name": "Spring framework study set",
  "structureJson": {
    "productIds": [
      "FBCUPOQsrp",
      "Y4LDaiViLY",
      "J6N3UWq9CK"
    ]
  },
  "ownerId": "mT9R9y6zGO"
}

{
  "lookupType": "PRODUCT_GROUP",
  "name": "Relational databases study set",
  "structureJson": {
    "productIds": [
      "QWQWQWQWQW",
      "XZXZXZXZXZ"
    ]
  },
  "ownerId": "mT9R9y6zGO"
}

...
我有一个复合GSI(ownerId-HASH,lookupType-RANGE)

当我尝试查询DDB(查询结构在“2”字段中)时,我得到了结果(结果在“3”中):

返回的结果集为空,尽管我有具有给定字段值的数据

我如何看待查询(或我想要实现的目标):

  • 当我使用
    ownerId=mT9R9y6zGO
    lookupType=PRODUCT\u GROUP
    查询GSI时,它将找到两个项—Spring和Relational DB集合
  • 作为第二步,DDB将使用
    contains(structureJson.productIds,FBCUPOQsrp)
    filter表达式扫描返回的查询结果,它应该向我返回一个结果,但我得到的是空集

  • 查询是否有问题,或者我是否遗漏了DDB查询工作流程中的某些要点?

    能否请您添加所做查询的整个结构?(per)你好,RyanMarvin!查询结构位于节点“2”下。我使用节点sdk(documentClient.query(params)函数)
    {
       "0":[
    
       ],
       "2":{
          "TableName":"Products",
          "IndexName":"ProductsOwnerIdLookupTypeIndex",
          "KeyConditionExpression":"#ownerId = :ownerId and #lookupType = :lookupType",
          "FilterExpression":"contains(#structureMember, :memberId)",
          "ExpressionAttributeNames":{
             "#ownerId":"ownerId",
             "#lookupType":"lookupType",
             "#structureMember":"structureJson.productIds"
          },
          "ExpressionAttributeValues":{
             ":ownerId":"mT9R9y6zGO",
             ":lookupType":"PRODUCT_GROUP",
             ":memberId":"FBCUPOQsrp"
          }
       },
       "3":{
          "Items":[
    
          ],
          "Count":0,
          "ScannedCount":2
       }
    }