Using Ruby variable in Rsolr requests

69 views Asked by At

Is it possible to send a request to Solr using a Ruby variable?

require 'rubygems'
require 'rsolr'

solr = RSolr.connect :url => 'http://solrserver.com'
response = rsolr.get 'select', :params => {:q => "prefName:#{params[:query]}"}

This code will generate a Bad Request error because the Ruby variable is ignored

RSolr::Error::Http - 400 Bad Request
Error: 'org.apache.solr.search.SyntaxError: Cannot parse \'prefName:\': Encountered "<EOF>" at line 1, column 9.
0

There are 0 answers