I’m building a small rails 3 app using mongodb (and mongoid) for my database.
I am using the mongoid_fulltext gem (https://github.com/aaw/mongoid_fulltext) to make my database searchable, which has worked fine so far.
However, I just tried testing the search functionality with words that include the characters ‘æøå’, and can see that I’m getting some invalid results.
It looks like mongoid_fulltext ignores these characters, such that the search string “københavn” becomes “kbenhavn”.
Does anyone now how to tell mongoid_fulltext to use UTF-8 encoding??
I’ve added # encoding: utf-8 To my model and my controller, which doesn’t work.
Okay, so I figured it out. If anyone is insterested, here my solution. You can add special characters by setting the alphabet paramter on you model, as such: fulltext_search_in :name, :city, :alphabet => ‘abcdefghijklmnopqrstuvwxyzæøå0123456789’ By default the parameter is set to: :alphabet => ‘abcdefghijklmnopqrstuvwxyz0123456789’