Skip to content

Instantly share code, notes, and snippets.

@nbraem
Forked from outoftime/function_query_spec.rb
Created March 15, 2010 21:56
Show Gist options
  • Save nbraem/333381 to your computer and use it in GitHub Desktop.
Save nbraem/333381 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 { :average_rating })
end
end
connection.should have_last_search_including(:bf, 'average_rating_f')
end
it "should handle arbitrary functions in a function query block" do
session.search Post do
keywords('pizza') do
boost(function { product(:average_rating, 10) })
end
end
connection.should have_last_search_including(:bf, '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(:average_rating, sum(:average_rating, 20)) })
end
end
connection.should have_last_search_including(:bf, 'product(average_rating_f,sum(average_rating_f,20))')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment