joshuabowers/search_magic — Issue #23: "embedded one to many" doesn't work
Author: lgs
Created: 2012-01-21 17:08:53+00:00
State: open

I have a User model

class User
include Mongoid::Document
field :name

embeds_many :watchlists
end

which embeds many Watchlist(s)

class Watchlist
include Mongoid::Document
include SearchMagic

field :description

embedded_in :user
search_on :description
end

But when I look for a string in description, which I know it exsist, I cannot find anything :

ruby-1.9.2-p290 :001 > User.all.map do |user|
ruby-1.9.2-p290 :002 > user.watchlists.search_for("It's a presentation framework based on").first
ruby-1.9.2-p290 :003?> end
MONGODB gitwatch_dev['system.namespaces'].find({})
MONGODB gitwatch_dev['users'].find({})
=> [nil]

specifiing the field searched it's the same :

ruby-1.9.2-p290 :004 > User.all.map do |user|
ruby-1.9.2-p290 :005 > user.watchlists.search_for("description:'a presentation framework based on'").first
ruby-1.9.2-p290 :006?> end
MONGODB gitwatch_dev['users'].find({})
=> [nil]
ruby-1.9.2-p290 :007 >

I tryed also with ather fields, no success. Do I miss something ?