简体   繁体   中英

How do we use LIKE operator or LIKE condition in DynamoDB?

我想获取数据/记录列表,就像 DynamoDB 中的 '%JUICE%' 有没有办法获取这样的数据?

DynamoDB is not good at wildcard searches. That being said, you do have a few options available to you:

  1. You can use the begins_with operator with sort keys . The docs say

begins_with (a, substr)— true if the value of attribute a begins with a particular substring

  1. The contains operator can be used on FilterExpression of scan operations on data types STRING, SET or LIST. More info in the docs .

Keep in mind that using the contains keyword on scan operations will be an inefficient way to implement wildcard searches in DynamoDB. You may be better off implementing this type of search outside of DynamoDB. A common pattern is to use DynamoDB streams and Elastic Search to implement a more full-featured search capability.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM