Skip to content

Instantly share code, notes, and snippets.

@outoftime
Created March 13, 2010 14:09
Show Gist options
  • Save outoftime/331335 to your computer and use it in GitHub Desktop.
Save outoftime/331335 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), 'spec_helper')
describe 'function query' do
it "should send query to solr with function query from a block" do
session.search Post do
keywords('pizza') do
boost(function { :ratings_average })
end
end
connection.should have_last_search_including(:bq => 'average_rating_f^2.0')
end
it "should handle arbitrary functions in a function query block" do
session.search Post do
keywords('pizza') do
boost(function { product(:ratings_average, 10) })
end
end
connection.should have_last_search_including(:bq => 'product(average_rating_f,10)')
end
it "should handle nested functions in a function query block" do
session.search Post do
keywords('pizza') do
boost(function { product(:ratings_average, sum(:ratings_average, 20)) })
end
end
connection.should have_last_search_including(:bq => 'product(average_rating_f,sum(average_rating_f,10))')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment