How to Add Filter in DynamoDB Query with Number Set using Java SDK/PartiQL?

0

Hi.

I have a table that has Number Set attribute, Field1.

Sample items

Field1 (Number Set)Field2Field3
[1,2,3]DataData
[2]DataData
[3]DataData
[2,4]DataData

How to Add Filter in DynamoDB Query with Number Set using Java SDK/PartiQL? The search sets only 1 param to get the items.

Sample scenario:

  • Include 2 as Field1 filter, the result should have rows #1, #2, #4.
  • Include 3 as Field1 filter. the result should have rows #1, #3.

Thank you!

已提問 2 年前檢視次數 827 次
1 個回答
1
已接受的答案

In the PartiQL query editor the queries would look like:

SELECT * FROM "tablename" WHERE contains("field1", 2)

SELECT * FROM "tablename" WHERE contains("field1", 3)

I have never created any JAVA client but reading the docs it would be someting like

statement = new ParameterizedStatement()
     .withStatement("SELECT * FROM 'tablename' WHERE contains('field1', ?)")
     .withParameters(new AttributeValue(2))
profile picture
JaccoPK
已回答 2 年前
  • cool! tried the PartiQL in the console and worked! greatly appreciate the answer.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南