lib/blacklight/solr/request.rb in blacklight-7.16.0 vs lib/blacklight/solr/request.rb in blacklight-7.17.0

- old
+ new

@@ -15,9 +15,40 @@ ARRAY_KEYS.each do |key| self[key] ||= [] end end + def append_query(query) + if self['q'] || dig(:json, :query, :bool) + self[:json] ||= { query: { bool: { must: [] } } } + self[:json][:query] ||= { bool: { must: [] } } + self[:json][:query][:bool][:must] << query + + if self['q'] + self[:json][:query][:bool][:must] << self['q'] + delete 'q' + end + else + self['q'] = query + end + end + + def append_boolean_query(bool_operator, query) + return if query.blank? + + self[:json] ||= { query: { bool: { bool_operator => [] } } } + self[:json][:query] ||= { bool: { bool_operator => [] } } + self[:json][:query][:bool][bool_operator] ||= [] + + if self['q'] + self[:json][:query][:bool][:must] ||= [] + self[:json][:query][:bool][:must] << self['q'] + delete 'q' + end + + self[:json][:query][:bool][bool_operator] << query + end + def append_filter_query(query) self['fq'] << query end def append_facet_fields(values)