MongoDB字符串查询中的比较
来源:互联网 发布:sql server参考手册 编辑:程序博客网 时间:2024/05/05 10:44
最近因为想了解一下MongoDB,就找了《MongoDB权威指南》来看,后来又想多了解一下别人的一些思路,遂报了官网的一个线上培训,以下是从他们上星期开始的一期在线培训的第二课中Inequalities On Strings中摘下来的一段,觉得有意思就手打出来了,算是给自己的一个备忘。
简言之,MongoDB将字符串按UTF-8进行字典排序,并可将$gt($ greater than,大于)和$lt($ less than,小于)用于字符串查询,原文如下:
Right now MongoDB has exactly zero knowledge of locales. In effect, the comparisons that we perform for $ less than, $ greater than an so forth are going to sort according to the total ordering of the UTF-8 code units. That is to say, according to a lexicographic sorting of the bytes in the UTF-8 representation of the string. This happens to be correct only in the POSIX or C locales. That is to say, MongoDB compares and sorts things in a Ascii-betically correct fashion. If it so happens that there's a local for which sorting things in UTF-8 byte order happens to be correct, then MongoDB happens to agree with that as well. A future release of MongoDB is likely to have better support locale-aware sorting collation, and so forth.
以下是培训课程中举的一个例子,列出所有name字段首字母在D前的文档:
>db.people.find( { name: { $lt:"D" } } );
- MongoDB字符串查询中的比较
- MongoDB比较查询操作符
- Mongodb中的like查询
- MongoDB中的数据查询
- MongoDB中的数据查询
- 字符串比较查询
- mongodb比较有用的查询技巧
- Java中的字符串比较
- ORACLEz中的字符串比较
- C#中的字符串比较
- JavaScript 中的字符串比较
- mongodb中字符串日期的比较
- Shell中的整数与字符串比较比较
- java MongoDB 字符串日期类型查询和日期类型查询
- .NET 2.0中的字符串比较
- c#中的字符串的比较
- 在JAVA中的字符串比较
- javascript中的字符串时间比较
- Ajax深入学习笔记
- iOS多种开源库实现上拉刷新下拉加载技巧
- 关于makefile需要掌握的知识
- 【绿皮】新GRE填空补充练习题Exercise10
- java基础集合框架——List、Set、Map概述(java集合一)
- MongoDB字符串查询中的比较
- 用NSDateFormatter调整时间格式的代码
- 【Unity3D ugui】简单控件的事件监听
- 使用MMX比较128位int
- 大文件的断点续传
- html学习笔记(1)——html基本格式
- Java继承中的构造方法
- .net c# outlook发送邀请功
- android中getSystemService详解