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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠