lib/blacklight/solr/repository.rb in blacklight-7.14.1 vs lib/blacklight/solr/repository.rb in blacklight-7.15.0
- old
+ new
@@ -56,11 +56,20 @@
# @overload find(params)
# @param [Hash] parameters for RSolr::Client#send_and_receive
# @return [Blacklight::Solr::Response] the solr response object
def send_and_receive(path, solr_params = {})
benchmark("Solr fetch", level: :debug) do
- key = blacklight_config.http_method == :post ? :data : :params
- res = connection.send_and_receive(path, { key => solr_params.to_hash, method: blacklight_config.http_method })
+ res = if solr_params[:json].present?
+ connection.send_and_receive(
+ path,
+ data: { params: solr_params.to_hash.except(:json) }.merge(solr_params[:json]).to_json,
+ method: :post,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+ else
+ key = blacklight_config.http_method == :post ? :data : :params
+ connection.send_and_receive(path, { key => solr_params.to_hash, method: blacklight_config.http_method })
+ end
solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model, blacklight_config: blacklight_config)
Blacklight.logger&.debug("Solr query: #{blacklight_config.http_method} #{path} #{solr_params.to_hash.inspect}")
Blacklight.logger&.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) && ::BLACKLIGHT_VERBOSE_LOGGING