2

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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
asprotte
  • 1,081
  • 1
  • 9
  • 12
  • 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'` – asprotte Dec 26 '12 at 20:54
  • Since you've found an answer to your question, it's also OK to post that below ;-) – Stennie Dec 31 '12 at 10:23

1 Answers1

1

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'

asprotte
  • 1,081
  • 1
  • 9
  • 12