gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:43 24 4
gpt4 key购买 nike

我想像我们在 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 is case sensitive. If your data is case insensitive, one solution is to lower case or upper case the data before storing it in DynamoDB. Then you can get around this by querying for all lower case or all upper case.

示例:

使用小写项目存储 postTitle

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

关于node.js - 如何在查询运行时将属性与 dynamodb 表 -> 项目 -> 属性中的小写值进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53076807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com