forked from sunspot/sunspot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added adjust_solr_params dsl logic, you are now able to changed all p…
…arameters passed to solr
- Loading branch information
Benjamin Krause
authored and
Mat Brown
committed
Oct 20, 2009
1 parent
945841a
commit 8d15e31
Showing
3 changed files
with
63 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require File.join(File.dirname(__FILE__), 'spec_helper') | ||
|
||
describe 'typed query' do | ||
it "should send query to solr with adjusted parameters (keyword example)" do | ||
session.search Post do | ||
keywords 'keyword search' | ||
adjust_solr_params do |params| | ||
params[:q] = 'new search' | ||
params[:some] = 'param' | ||
end | ||
end | ||
connection.should have_last_search_with(:q => 'new search') | ||
connection.should have_last_search_with(:some => 'param') | ||
end | ||
|
||
it "should work, even without another dsl command" do | ||
session.search Post do | ||
adjust_solr_params do |params| | ||
params[:q] = 'napoleon dynamite' | ||
params[:qt] = 'complicated' | ||
end | ||
end | ||
connection.should have_last_search_with(:q => 'napoleon dynamite') | ||
connection.should have_last_search_with(:qt => 'complicated') | ||
end | ||
|
||
it "should be able to extend parameters" do | ||
session.search Post do | ||
keywords 'keyword search' | ||
adjust_solr_params do |params| | ||
params[:q] += ' AND something_s:more' | ||
end | ||
end | ||
connection.should have_last_search_with(:q => 'keyword search AND something_s:more') | ||
end | ||
|
||
end |