Can't not search non-unicode in mongodb

183 views
Skip to first unread message

Nguyên Nguyễn Thế

unread,
Jan 9, 2014, 9:07:51 PM1/9/14
to mongod...@googlegroups.com
Hi all, thank to read my post!!!
I have data: "Tôi yêu cộng đồng Mongodb"
if my search string is "cộng đồng", Mongodb return data, but search string is "cong dong" not return.
Please help me!

nguyen sang

unread,
Jan 9, 2014, 9:41:57 PM1/9/14
to mongod...@googlegroups.com
hi,
You should add new field to store this string "cong dong" then seaching in it.
thanks!


2014/1/10 Nguyên Nguyễn Thế <thenguy...@gmail.com>

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
             *** ***
      Nguyễn Văn Sang      
      Mobile:   01 656 054 323
      Email:    Sang...@gmail.com
      Skype:   Sang89vh

Nguyên Nguyễn Thế

unread,
Jan 10, 2014, 10:32:28 AM1/10/14
to mongod...@googlegroups.com
Thank to nguyen sang!
That seem not good,  have better way?

Vào 09:07:51 UTC+7 Thứ sáu, ngày 10 tháng một năm 2014, Nguyên Nguyễn Thế đã viết:

Ger Hartnett

unread,
Jan 15, 2014, 4:40:47 AM1/15/14
to mongod...@googlegroups.com
You could transform the search string into a regex that matches the unicode and non-unicode characters.

For example:

With these documents:
> db.t38528.find()
{ "_id" : ObjectId("52d6553a46fc814f046fa733"), "text" : "Tôi yêu cộng đồng Mongodb" }
{ "_id" : ObjectId("52d656d146fc814f046fa735"), "text" : "yeu cong dồng" }

This query will find any mix of unicode/non-unicode:
> db.t38528.find({text: /c(ộ|o)ng (đ|d)(ồ|o)ng/i })
{ "_id" : ObjectId("52d6553a46fc814f046fa733"), "text" : "Tôi yêu cộng đồng Mongodb" }
{ "_id" : ObjectId("52d656d146fc814f046fa735"), "text" : "yeu cong dồng" }

/ger.
Reply all
Reply to author
Forward
0 new messages