DynamoDB PartiQL: query on map key

0

Hello,

Could you please correct the following query so that to work in DynamoDB PartiQL ?

For the table "PicturesTagging" with item structure:

{
  "PictureS3BucketKeyPK": {
    "S": "pics-repository#pics#samsung_M#2021#2021.01.06_jumbo_craciun#20210102_120050.jpg"
  },
  "TagsTool": {
    "S": "aws_rekognition_worker_labels_no_params"
  },
  "Tags": {
    "M": {
      "personal:data:content:labels:dominant_category": {
        "S": "Buildings and Architecture"
      },
      "personal:data:content:labels:dominant_label": {
        "S": "Building"
      }
    }
  }
}

I need to get those items that contains a certain key fragment:

SELECT PictureS3BucketKeyPK, Tags
FROM PicturesTagging 
where begins_with("Tags", 'personal:data:content:labels:')

The query runs succesfully, but it returns no items, while the table has a lot like those.

Thank you,
Mihai ADAM

gefragt vor 10 Monaten751 Aufrufe
1 Antwort
0

Hi

In your Table the Tags attribute is a Map with two attributes personal:data:content:labels:dominant_category and personal:data:content:labels:dominant_label, in your query it looks like you are trying to query on the attribute name, that is not possible you need to query on the values.

A query to fetch all items that has the personal:data:content:labels:dominant_label attribute with a value that starts with Building would look like this:

SELECT PictureS3BucketKeyPK, Tags
FROM PicturesTagging 
where begins_with("Tags"."personal:data:content:labels:dominant_label", 'Building')

Hope it helps.

profile picture
EXPERTE
beantwortet vor 10 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen