Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only call the SearchBuilder one time per request #3157

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/blacklight/solr/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ def find id, params = {}

##
# Execute a search query against solr
# @param [Hash] params solr query parameters
def search params = {}
send_and_receive search_path(params), params.reverse_merge(qt: blacklight_config.qt)
# @param [SearchBuilder] search_builder solr query parameters
def search search_builder = {}
request_params = search_builder.to_hash

send_and_receive search_path(request_params), request_params.reverse_merge(qt: blacklight_config.qt)
end

# @param [Hash] request_params
Expand Down Expand Up @@ -62,7 +64,7 @@ def send_and_receive(path, solr_params = {})
res = connection.send_and_receive(path, build_solr_request(solr_params))
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 query: #{blacklight_config.http_method} #{path} #{solr_params.inspect}")
Blacklight.logger&.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) && ::BLACKLIGHT_VERBOSE_LOGGING
solr_response
end
Expand All @@ -80,14 +82,14 @@ def send_and_receive(path, solr_params = {})
def build_solr_request(solr_params)
if uses_json_query_dsl?(solr_params)
{
data: { params: solr_params.to_hash.except(:json) }.merge(solr_params[:json]).to_json,
data: { params: solr_params.except(:json) }.merge(solr_params[:json]).to_json,
method: :post,
headers: { 'Content-Type' => 'application/json' }
}
else
key = blacklight_config.http_method == :post ? :data : :params
{
key => solr_params.to_hash,
key => solr_params,
method: blacklight_config.http_method
}
end
Expand Down
Loading