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

Version Path
sunspot_mongoid2-0.5.1.7 examples/example.rb
sunspot_mongoid2-0.5.1.5 examples/example.rb
sunspot_mongoid-0.4.1 examples/example.rb
aq1018-sunspot_mongoid-0.5.0 examples/example.rb
aq1018-sunspot_mongoid-0.4.0 examples/example.rb
vinova_sunspot_mongoid-0.3.5 examples/example.rb
sunspot_mongoid-0.4.0 examples/example.rb
vinova_sunspot_mongoid-0.3.4 examples/example.rb
sunspot_mongoid-0.3.2 examples/example.rb
sunspot_mongoid-0.3.1 examples/example.rb
sunspot_mongoid-0.3.0 examples/example.rb
sunspot_mongoid-0.2.0 examples/example.rb