是否可以使用 Ruby 变量向 Solr 发送请求?
require 'rubygems'
require 'rsolr'
solr = RSolr.connect :url => 'http://solrserver.com'
response = rsolr.get 'select', :params => {:q => "prefName:#{params[:query]}"}
此代码将生成错误请求错误,因为忽略了 Ruby 变量
RSolr::Error::Http - 400 Bad Request
Error: 'org.apache.solr.search.SyntaxError: Cannot parse \'prefName:\': Encountered "<EOF>" at line 1, column 9.