查询不区分大小写的DynamoDB [英] Query DynamoDB with case-insensitive condition

查看:214
本文介绍了查询不区分大小写的DynamoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将组织名称存储在AWS上的DynamoDB表中,并希望维护这些公司名称的正式大写形式,例如,在"TNT"和"FedEx"中.

We're storing organization names in a DynamoDB table on AWS, and would like to maintain official capitalization in those business names, for example in "TNT" and "FedEx".

我们的用例是应用程序的用户可以按名称搜索组织,但是我们希望对他们的查询进行区分大小写.因此,对"FedEx","Fedex"或"fedex"的查询都应返回表中的正确项目.

Our use case is that users of the application can search for organizations by name, but we'd like that their queries are interpreted case-insensitively. So, queries for "FedEx", "Fedex" or "fedex" should all return the correct item in the table.

其他数据库可以通过忽略正则表达式来表达查询,或者通过在条件中应用函数(例如LOWER()函数)来执行忽略大小写的查询(例如,通过PostgreSQL中的ILIKE关键字).

Other databases have ways to perform queries ignoring case (for example by the ILIKE key word in PostgreSQL), by expressing queries via regular expressions, or by applying functions in the condition (for example the LOWER() function).

如何在DynamoDB中完成此操作? <有关Amazon DynamoDB的查询的文档没有提供答案.

How can this be done in DynamoDB? The documentation on Amazon DynamoDB's Query does not provide an answer.

(最好的解决方法似乎是将名称存储两次:一次使用正式大写字母,一次存储在另一个名称转换为小写字母的字段中.然后,应在第二个字段中使用查询进行搜索搜索字词也转换为小写.是的,我知道它为表增加了冗余.这是一种变通方法,而不是最佳解决方案.)

(The best work-around seems to be storing the name twice: once with the official capitalization in effect, and once in another field with the name converted to lowercase. Searching should then be done on the latter field, with the query search term also converted to lowercase. Yes, I know it adds redundancy to the table. It's a work-around, not an optimal solution.)

推荐答案

是的,确切地说,当您添加新项/行时,还要添加一个新字段searchName,即小写字母(甚至更多,也许只有字母/数字)/spaces).然后按该searchName字段进行搜索

yes, exactly, when you add the new item/row, add also a new field searchName, that is the lowercase (even more, maybe only letters/numbers/spaces) of the your name field. and then search by that searchName field

这篇关于查询不区分大小写的DynamoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆