繁体   English   中英

我如何在查询运行时将属性与dynamodb表->项目->属性中的小写值进行比较

[英]How do I compare attribute to a lower case value in dynamodb table -> Item -> attribute in query runtime

我想像在mysql LOWER(fieldName)= LIKE%strtolower(search_text)%中一样在属性中搜索文本字符串。 我做了一些,但没有找到任何解决方案。

{
    "TableName": "DEV_postTbl",
    "ProjectionExpression": "postId, postType, postStatus",
    "ScanIndexForward": false,
    "Limit": 6,
    "KeyConditionExpression": "postStatus =:postStatusPublished",
    "IndexName": "postStatus-createdOn-index",
    "FilterExpression": " (  contains( postTitle, :searchText)  OR  contains(postDescription, :searchText) OR contains(postLocation.addressLine, :searchText) ) ",
    "ExpressionAttributeValues": {
        ":searchText": "hello",
        ":postStatusPublished": "published"
    }
}

这是我的代码..但是这样的搜索仅是“ hello”而不是“ hello”,“ heLLO”

DynamoDB区分大小写。 如果您的数据不区分大小写,则一种解决方案是将数据存储在DynamoDB中之前将其转换为小写或大写形式。 然后,您可以通过查询所有小写字母或所有大写字母来解决此问题。

范例:

postTitle项目存储postTitle

当您搜索只是小写:searchTex (str.toLowerCase()),然后查询。

暂无
暂无

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

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