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!

gefragt vor 2 Jahren827 Aufrufe
1 Antwort
1
Akzeptierte Antwort

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
beantwortet vor 2 Jahren
  • cool! tried the PartiQL in the console and worked! greatly appreciate the answer.

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