lib/blacklight/solr/search_builder_behavior.rb in blacklight-7.15.2 vs lib/blacklight/solr/search_builder_behavior.rb in blacklight-7.16.0

- old
+ new

@@ -57,10 +57,12 @@ # solr LocalParams in config, using solr LocalParams syntax. # http://wiki.apache.org/solr/LocalParams ## if search_field&.query_builder.present? add_search_field_query_builder_params(solr_parameters) + elsif search_field&.clause_params.present? + add_search_field_with_json_query_parameters(solr_parameters) elsif search_field&.solr_local_parameters.present? add_search_field_with_local_parameters(solr_parameters) elsif search_state.query_param.is_a? Hash add_additional_filters(solr_parameters, search_state.query_param) elsif search_state.query_param @@ -84,10 +86,18 @@ solr_parameters[:defType] = 'lucene' solr_parameters[:spellcheck] = 'false' end + def add_search_field_with_json_query_parameters(solr_parameters) + bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) } + + solr_parameters[:json] ||= { query: { bool: { must: [] } } } + solr_parameters[:json][:query] ||= { bool: { must: [] } } + solr_parameters[:json][:query][:bool][:must] << bool_query + end + # Transform "clause" parameters into the Solr JSON Query DSL def add_adv_search_clauses(solr_parameters) return if search_state.clause_params.blank? defaults = { must: [], must_not: [], should: [] } @@ -365,10 +375,10 @@ end ## # The key to use to retrieve the grouped field to display def grouped_key_for_results - blacklight_config.index.group + blacklight_config.view_config(action_name: :index).group end def facet_fields_to_include_in_request blacklight_config.facet_fields.select do |_field_name, facet| facet.include_in_request || (facet.include_in_request.nil? && blacklight_config.add_facet_fields_to_solr_request)