如何使用 Google App Engine 进行不区分大小写的过滤器查询? [英] How to make case insensitive filter queries with Google App Engine?

查看:18
本文介绍了如何使用 Google App Engine 进行不区分大小写的过滤器查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个 GAE Django 项目,我必须在其中实现搜索功能,我编写了一个查询,它根据搜索关键字获取数据.

I am working on a GAE Django Project where I have to implementing the search functionality, I have written a query and it fetches the data according to the search keyword.

portfolio = Portfolio.all().filter('full_name >=',key).filter('full_name <',unicode(key) + u'ufffd')

这个查询的问题是,它区分大小写.

The issue with this query is, that it is case sensitive.

有什么方法可以让它工作,而不依赖于关键字的大小写?

Is there any way through which I can make it to work, without depending upon the case of the keyword?

请提出建议.

提前致谢.

推荐答案

您需要在写入时存储数据的规范化版本,然后使用相同的规范化进行搜索.

You need to store normalized versions of your data at write time, then use the same normalization to search.

将数据存储为全部大写或全部小写,可选择删除标点符号并将所有空格更改为单个空格,并且可能将非 ASCII 字符转换为一些合理的 ASCII 表示(当然,这比听起来更棘手.)

Store the data either all uppercase or all lowercase, optionally removing punctuation and changing all whitespace to a single space and maybe converting non-ASCII characters to some reasonable ASCII representation (which is, of course, trickier than it sounds.)

这篇关于如何使用 Google App Engine 进行不区分大小写的过滤器查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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