forked from sunspot/sunspot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sunspot#470 from mikeauclair/solr_joins
Solr joins
- Loading branch information
Showing
9 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require File.expand_path('spec_helper', File.dirname(__FILE__)) | ||
|
||
describe 'join' do | ||
it 'should search by join' do | ||
session.search PhotoContainer do | ||
with(:caption, 'blah') | ||
end | ||
connection.should have_last_search_including( | ||
:fq, "{!join from=photo_container_id to=id}caption_s:blah") | ||
end | ||
|
||
it 'should greater_than search by join' do | ||
session.search PhotoContainer do | ||
with(:photo_rating).greater_than(3) | ||
end | ||
connection.should have_last_search_including( | ||
:fq, "{!join from=photo_container_id to=id}average_rating_ft:{3\\.0 TO *}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
class Photo < MockRecord | ||
attr_accessor :caption, :lat, :lng, :size, :average_rating, :created_at | ||
attr_accessor :caption, :lat, :lng, :size, :average_rating, :created_at, :post_id, :photo_container_id | ||
end | ||
|
||
Sunspot.setup(Photo) do | ||
text :caption, :default_boost => 1.5 | ||
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 | ||
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 |