aaw/mongoid_fulltext — Issue #41: Search in hash or array field
Author: karb
Created: 2012-02-01 10:52:20+00:00
State: open

I have a model that, besides regular string fields, also has a `Hash` and an `Array` field.
I am trying to convert all the 'text' in the hash to a long string but the *fulltext_search_in* only accepts a string, not a method which returns a string. I've tried it with `return Proc.new {}` but
For the array field it would be pretty straightforward to make that searchable, but for the hash I am kinda lost. This is what I have and throws me an `undefined method 'tr'` which tells me not much. The beneath gives me an `undefined method 'each'` probably because it needs a String and no function?

```ruby
field :name
field :lineup, type: Hash
field :genre, type: Array

fulltext_search_in :name, :index_name => 'name_index'
fulltext_search_in :genre_string, :index_name => 'genre_index'
fulltext_search_in :lineup_string, :index_name => 'lineup_index'

def genre_string
genre.join(' ')
end

def lineup_string
artists = ''
lineup.each do |a|
a.each do |k,v|
djs << "#{k["artist"]} "
end
end
artists
end
```

Thanks in advance for any help with this.