Sha256: 338f05738a6ec1283f09d97d43d57532adba06af2ecaa3e3d91ab549b2ba00ff
Contents?: true
Size: 602 Bytes
Versions: 12
Compression:
Stored size: 602 Bytes
Contents
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'sunspot_mongoid' Mongoid.configure do |config| config.master = Mongo::Connection.new.db('sunspot-mongoid-test') end # model class Post include Mongoid::Document field :title include Sunspot::Mongoid searchable do text :title end end # remove old indexes Post.destroy_all # indexing Post.create(:title => 'foo') Post.create(:title => 'foo bar') Post.create(:title => 'bar baz') # commit Sunspot.commit # search search = Post.search do keywords 'foo' end search.each_hit_with_result do |hit, post| p post end
Version data entries
12 entries across 12 versions & 4 rubygems