spec/mocks/photo.rb in sunspot-2.1.1 vs spec/mocks/photo.rb in sunspot-2.2.0
- old
+ new
@@ -1,24 +1,32 @@
class Photo < MockRecord
- attr_accessor :caption, :lat, :lng, :size, :average_rating, :created_at, :post_id, :photo_container_id
+ attr_accessor :caption, :description, :lat, :lng, :size, :average_rating, :created_at, :post_id, :photo_container_id
end
Sunspot.setup(Photo) do
text :caption, :default_boost => 1.5
+ text :description
string :caption
integer :photo_container_id
boost 0.75
integer :size, :trie => true
float :average_rating, :trie => true
time :created_at, :trie => true
end
class PhotoContainer < MockRecord
+ attr_accessor :description
+
def id
1
end
end
Sunspot.setup(PhotoContainer) do
- join(:caption, :type => :string, :join_string => 'from=photo_container_id to=id')
- join(:photo_rating, :type => :trie_float, :join_string => 'from=photo_container_id to=id', :as => 'average_rating_ft')
-end
\ No newline at end of file
+ integer :id
+ text :description, :default_boost => 1.2
+
+ join(:caption, :target => Photo, :type => :string, :join => { :from => :photo_container_id, :to => :id })
+ join(:photo_rating, :target => Photo, :type => :trie_float, :join => { :from => :photo_container_id, :to => :id }, :as => 'average_rating_ft')
+ join(:caption, :target => Photo, :type => :text, :join => { :from => :photo_container_id, :to => :id })
+ join(:description, :prefix => "photo", :target => Photo, :type => :text, :join => { :from => :photo_container_id, :to => :id })
+end