简体   繁体   English

DynamoDB 获取属性值为 substring 的项目

[英]DynamoDB get items with an attribute that is a substring of a value

I'm trying to query items in DynamoDB checking if one of their attributes is a substring of a provided value.我正在尝试查询 DynamoDB 中的项目,检查它们的属性之一是否为提供值的 substring。

So basically, I am trying to do a query using something similar to contains(attribute_name, :input_value) but like this instead: contains(:input_value, attribute_name) (check if the attribute is inside the input value)所以基本上,我正在尝试使用类似于contains(attribute_name, :input_value)的东西进行查询,但像这样: contains(:input_value, attribute_name) (检查属性是否在输入值内)

Ex: If my items have the following attributes:例如:如果我的物品具有以下属性:

---------------------
 item_id |  domain
---------------------
1        | amazon.com
---------------------
2        | amazon.com
---------------------
3        | google.com
---------------------

And I use 'https://us-east-1.console.aws.amazon.com/' as input I want the 2 first items to be returned from the query.我使用'https://us-east-1.console.aws.amazon.com/'作为输入,我希望从查询中返回前 2 个项目。

Is there a way to make something like this in DynamoDB?有没有办法在 DynamoDB 中制作这样的东西?

No, you cannot do a substring match in reverse.不,您不能反向进行 substring 匹配。 Before making the request to DynamoDB you should remove only the domain portion from the string as thats what you want to evaluate on.在向 DynamoDB 发出请求之前,您应该只从字符串中删除域部分,因为这就是您要评估的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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