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

查看:133
本文介绍了如何使用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天全站免登陆