Sha256: 6d6917de956f11063c72a29dbe04a8d27c2c861133170508086460b59c1ba7b5

Contents?: true

Size: 1.39 KB

Versions: 42

Compression:

Stored size: 1.39 KB

Contents

require File.expand_path('spec_helper', File.dirname(__FILE__))

describe 'indexing fulltext fields' do
  it 'indexes text field' do
    session.index(post(:title => 'A Title'))
    connection.should have_add_with(:title_text => 'A Title')
  end

  it 'indexes stored text field' do
    session.index(post(:body => 'Test body'))
    connection.should have_add_with(:body_textsv => 'Test body')
  end

  it 'indexes text field with boost' do
    session.index(post(:title => 'A Title'))
    connection.adds.last.first.field_by_name(:title_text).attrs[:boost].should == 2
  end

  it 'indexes multiple values for a text field' do
    session.index(post(:body => %w(some title)))
    connection.should have_add_with(:body_textsv => %w(some title))
  end

  it 'indexes text via a block accessor' do
    session.index(post(:title => 'backwards'))
    connection.should have_add_with(:backwards_title_text => 'sdrawkcab')
  end

  it 'indexes document level boost using block' do
    session.index(post(:ratings_average => 4.0))
    connection.adds.last.first.attrs[:boost].should == 1.25
  end

  it 'indexes document level boost using attribute' do
    session.index(Namespaced::Comment.new(:boost => 1.5))
    connection.adds.last.first.attrs[:boost].should == 1.5
  end

  it 'indexes document level boost defined statically' do
    session.index(Photo.new)
    connection.adds.last.first.attrs[:boost].should == 0.75
  end
end

Version data entries

42 entries across 42 versions & 10 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sunspot-2.2.7/spec/api/indexer/fulltext_spec.rb
sunspot-2.2.7 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.6 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.5 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.4 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.3 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.2 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.1 spec/api/indexer/fulltext_spec.rb
sunspot-2.2.0 spec/api/indexer/fulltext_spec.rb
sunspot-2.1.1 spec/api/indexer/fulltext_spec.rb
sunspot-2.1.0 spec/api/indexer/fulltext_spec.rb
sunspot-2.0.0 spec/api/indexer/fulltext_spec.rb
sunspot-2.0.0.pre.130115 spec/api/indexer/fulltext_spec.rb
gojee-sunspot-2.0.5 spec/api/indexer/fulltext_spec.rb
sunspot-2.0.0.pre.120925 spec/api/indexer/fulltext_spec.rb
sunspot_solr-2.0.0.pre.120924 sunspot/spec/api/indexer/fulltext_spec.rb
sunspot_rails-2.0.0.pre.120924 sunspot/spec/api/indexer/fulltext_spec.rb
sunspot-2.0.0.pre.120924 sunspot/spec/api/indexer/fulltext_spec.rb
gojee-sunspot-2.0.4 spec/api/indexer/fulltext_spec.rb
gojee-sunspot-2.0.2 spec/api/indexer/fulltext_spec.rb