blacklight 7.14.1 → 7.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_icons.scss +5 -1
  5. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -0
  6. data/app/components/blacklight/advanced_search_form_component.html.erb +52 -0
  7. data/app/components/blacklight/advanced_search_form_component.rb +88 -0
  8. data/app/components/blacklight/constraint_component.html.erb +1 -1
  9. data/app/components/blacklight/constraint_layout_component.html.erb +1 -1
  10. data/app/components/blacklight/constraints_component.html.erb +19 -3
  11. data/app/components/blacklight/constraints_component.rb +41 -18
  12. data/app/components/blacklight/content_areas_shim.rb +12 -0
  13. data/app/components/blacklight/document/action_component.html.erb +1 -1
  14. data/app/components/blacklight/document/action_component.rb +6 -1
  15. data/app/components/blacklight/document/actions_component.html.erb +3 -5
  16. data/app/components/blacklight/document/actions_component.rb +16 -2
  17. data/app/components/blacklight/document/thumbnail_component.html.erb +1 -1
  18. data/app/components/blacklight/document/thumbnail_component.rb +4 -1
  19. data/app/components/blacklight/document_component.html.erb +4 -7
  20. data/app/components/blacklight/document_component.rb +73 -68
  21. data/app/components/blacklight/document_metadata_component.html.erb +2 -2
  22. data/app/components/blacklight/document_metadata_component.rb +13 -2
  23. data/app/components/blacklight/document_title_component.html.erb +17 -0
  24. data/app/components/blacklight/document_title_component.rb +59 -0
  25. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +23 -0
  26. data/app/components/blacklight/facet_field_checkboxes_component.rb +24 -0
  27. data/app/components/blacklight/facet_field_component.rb +4 -1
  28. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +6 -0
  29. data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +29 -0
  30. data/app/components/blacklight/facet_field_list_component.html.erb +3 -2
  31. data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
  32. data/app/components/blacklight/facet_field_pagination_component.rb +1 -1
  33. data/app/components/blacklight/facet_item_component.rb +4 -2
  34. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  35. data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
  36. data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
  37. data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
  38. data/app/components/blacklight/response/view_type_button_component.rb +36 -0
  39. data/app/components/blacklight/response/view_type_component.html.erb +2 -5
  40. data/app/components/blacklight/response/view_type_component.rb +9 -13
  41. data/app/components/blacklight/search_bar_component.html.erb +4 -0
  42. data/app/components/blacklight/search_bar_component.rb +13 -4
  43. data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
  44. data/app/components/blacklight/system/dropdown_component.rb +24 -0
  45. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  46. data/app/components/blacklight/system/flash_message_component.rb +7 -1
  47. data/app/components/blacklight/system/modal_component.rb +7 -1
  48. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  49. data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
  50. data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
  51. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
  52. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
  53. data/app/presenters/blacklight/clause_presenter.rb +37 -0
  54. data/app/presenters/blacklight/document_presenter.rb +13 -5
  55. data/app/presenters/blacklight/facet_field_presenter.rb +4 -0
  56. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +45 -0
  57. data/app/presenters/blacklight/facet_item_presenter.rb +32 -20
  58. data/app/presenters/blacklight/inclusive_facet_item_presenter.rb +16 -0
  59. data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
  60. data/app/presenters/blacklight/search_bar_presenter.rb +4 -0
  61. data/app/services/blacklight/search_service.rb +1 -1
  62. data/app/views/bookmarks/_tools.html.erb +1 -1
  63. data/app/views/catalog/_advanced_search_form.html.erb +7 -0
  64. data/app/views/catalog/_advanced_search_help.html.erb +24 -0
  65. data/app/views/catalog/_citation.html.erb +1 -1
  66. data/app/views/catalog/_document.html.erb +2 -2
  67. data/app/views/catalog/_facet_layout.html.erb +2 -2
  68. data/app/views/catalog/_search_form.html.erb +1 -0
  69. data/app/views/catalog/_show_main_content.html.erb +3 -3
  70. data/app/views/catalog/advanced_search.html.erb +17 -0
  71. data/app/views/catalog/email.html.erb +2 -2
  72. data/app/views/catalog/email_success.html.erb +1 -1
  73. data/app/views/catalog/facet.html.erb +3 -3
  74. data/app/views/catalog/sms.html.erb +2 -2
  75. data/app/views/catalog/sms_success.html.erb +1 -1
  76. data/blacklight.gemspec +2 -2
  77. data/config/i18n-tasks.yml +1 -0
  78. data/config/locales/blacklight.de.yml +2 -2
  79. data/config/locales/blacklight.en.yml +17 -0
  80. data/lib/blacklight/configuration.rb +52 -6
  81. data/lib/blacklight/configuration/view_config.rb +16 -5
  82. data/lib/blacklight/engine.rb +3 -1
  83. data/lib/blacklight/open_struct_with_hash_access.rb +22 -1
  84. data/lib/blacklight/routes/searchable.rb +1 -0
  85. data/lib/blacklight/search_builder.rb +2 -0
  86. data/lib/blacklight/search_state.rb +7 -3
  87. data/lib/blacklight/search_state/filter_field.rb +17 -7
  88. data/lib/blacklight/solr/facet_paginator.rb +2 -0
  89. data/lib/blacklight/solr/repository.rb +11 -2
  90. data/lib/blacklight/solr/request.rb +31 -0
  91. data/lib/blacklight/solr/response.rb +2 -16
  92. data/lib/blacklight/solr/response/facets.rb +76 -22
  93. data/lib/blacklight/solr/response/params.rb +104 -0
  94. data/lib/blacklight/solr/search_builder_behavior.rb +126 -32
  95. data/lib/generators/blacklight/assets_generator.rb +6 -2
  96. data/lib/generators/blacklight/user_generator.rb +1 -1
  97. data/spec/components/blacklight/advanced_search_form_component_spec.rb +51 -0
  98. data/spec/components/blacklight/document_component_spec.rb +18 -3
  99. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +55 -0
  100. data/spec/components/blacklight/facet_field_list_component_spec.rb +39 -4
  101. data/spec/controllers/catalog_controller_spec.rb +9 -0
  102. data/spec/features/advanced_search_spec.rb +67 -0
  103. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  104. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +20 -0
  105. data/spec/lib/blacklight/search_state/filter_field_spec.rb +65 -0
  106. data/spec/models/blacklight/configuration_spec.rb +64 -0
  107. data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
  108. data/spec/models/blacklight/solr/repository_spec.rb +12 -0
  109. data/spec/models/blacklight/solr/request_spec.rb +62 -29
  110. data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
  111. data/spec/models/blacklight/solr/response_spec.rb +10 -0
  112. data/spec/models/blacklight/solr/search_builder_spec.rb +77 -0
  113. data/spec/presenters/blacklight/clause_presenter_spec.rb +34 -0
  114. data/spec/presenters/blacklight/document_presenter_spec.rb +13 -0
  115. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +41 -0
  116. data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
  117. metadata +37 -9
@@ -18,3 +18,4 @@ search:
18
18
 
19
19
  ignore_missing:
20
20
  - 'button_label_html'
21
+ - 'blacklight.advanced_search.*'
@@ -3,7 +3,7 @@ de:
3
3
  pagination:
4
4
  first: '« Erste'
5
5
  last: 'Letzte »'
6
- previous: '« Voherige'
6
+ previous: '« Vorherige'
7
7
  next: 'Nächste »'
8
8
  truncate: '…'
9
9
  aria:
@@ -16,7 +16,7 @@ de:
16
16
  go_to_previous_page: Zurück zur letzten Seite
17
17
 
18
18
  pagination_compact:
19
- previous: '« Voherige'
19
+ previous: '« Vorherige'
20
20
  next: 'Nächste »'
21
21
 
22
22
  blacklight:
@@ -239,3 +239,20 @@ en:
239
239
  main:
240
240
  aria:
241
241
  main_container: 'Main content'
242
+
243
+ advanced_search:
244
+ or_html: ' OR '
245
+ more_options: More options
246
+ any_of: 'Any of:'
247
+ op:
248
+ must: all
249
+ should: any
250
+ page_title: Advanced search - %{application_name}
251
+ form:
252
+ title: Advanced search
253
+ search_context: Within search
254
+ limit_criteria_heading_html: "<strong>AND</strong> have these attributes"
255
+ query_criteria_heading_html: "Match %{select_menu} of the fields below"
256
+ sort_label: "Sort results by"
257
+ start_over_html: "Start over"
258
+ search_btn_html: 'Search'
@@ -95,6 +95,12 @@ module Blacklight
95
95
  partials: [:show_header, :show],
96
96
  document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
97
97
  ),
98
+ action_mapping: NestedOpenStructWithHashAccess.new(
99
+ ViewConfig,
100
+ default: { top_level_config: :index },
101
+ show: { top_level_config: :show },
102
+ citation: { parent_config: :show }
103
+ ),
98
104
  # Configurations for specific types of index views
99
105
  view: NestedOpenStructWithHashAccess.new(ViewConfig,
100
106
  list: {},
@@ -132,7 +138,8 @@ module Blacklight
132
138
  crawler_detector: nil,
133
139
  autocomplete_suggester: 'mySuggester',
134
140
  raw_endpoint: OpenStructWithHashAccess.new(enabled: false),
135
- track_search_session: true
141
+ track_search_session: true,
142
+ advanced_search: OpenStruct.new(enabled: false)
136
143
  }
137
144
  end
138
145
  # rubocop:enable Metrics/MethodLength
@@ -306,13 +313,35 @@ module Blacklight
306
313
  end
307
314
  alias_method :inheritable_copy, :build
308
315
 
309
- # Get a view configuration for the given view type
310
- # including default values from the index configuration
316
+ # Get a view configuration for the given view type + action. The effective
317
+ # view configuration is inherited from:
318
+ # - the configuration from blacklight_config.view with the key `view_type`
319
+ # - the configuration from blacklight_config.action_mapping with the key `action_name`
320
+ # - any parent config for the action map result above
321
+ # - the action_mapping default configuration
322
+ # - the top-level index/show view configuration
323
+ #
311
324
  # @param [Symbol,#to_sym] view_type
312
325
  # @return [Blacklight::Configuration::ViewConfig]
313
- def view_config(view_type)
314
- view_type = view_type.to_sym unless view_type.is_a? Symbol
315
- index.merge(view_type == :show ? show : view.fetch(view_type, {}))
326
+ def view_config(view_type = nil, action_name: :index)
327
+ view_type &&= view_type.to_sym
328
+ action_name &&= action_name.to_sym
329
+ action_name ||= :index
330
+
331
+ if view_type == :show
332
+ action_name = view_type
333
+ view_type = nil
334
+ end
335
+
336
+ @view_config ||= {}
337
+ @view_config[[view_type, action_name]] ||= begin
338
+ if view_type.nil?
339
+ action_config(action_name)
340
+ else
341
+ base_config = action_config(action_name)
342
+ base_config.merge(view.fetch(view_type, {}))
343
+ end
344
+ end
316
345
  end
317
346
 
318
347
  # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
@@ -440,5 +469,22 @@ module Blacklight
440
469
  yield(object)
441
470
  end
442
471
  end
472
+
473
+ def action_config(action, default: :index)
474
+ action_config = action_mapping[action]
475
+ action_config ||= action_mapping[:default]
476
+
477
+ if action_config.parent_config && action_config.parent_config != :default
478
+ parent_config = action_mapping[action_config.parent_config]
479
+ raise "View configuration error: the parent configuration of #{action_config.key}, #{parent_config.key}, must not specific its own parent configuration" if parent_config.parent_config
480
+
481
+ action_config = action_config.reverse_merge(parent_config)
482
+ end
483
+ action_config = action_config.reverse_merge(action_mapping[:default]) if action_config != action_mapping[:default]
484
+
485
+ action_config = action_config.reverse_merge(self[action_config.top_level_config]) if action_config.top_level_config
486
+ action_config = action_config.reverse_merge(show) if default == :show && action_config.top_level_config != :show
487
+ action_config.reverse_merge(index)
488
+ end
443
489
  end
444
490
  end
@@ -17,15 +17,18 @@ class Blacklight::Configuration
17
17
  super || Blacklight::SearchBarPresenter
18
18
  end
19
19
 
20
- def display_label(key)
20
+ def display_label(deprecated_key = nil, **options)
21
+ Deprecation.warn('Passing the key argument to ViewConfig#display_label is deprecated') if deprecated_key.present?
22
+
21
23
  I18n.t(
22
- :"blacklight.search.view_title.#{key}",
24
+ :"blacklight.search.view_title.#{deprecated_key || key}",
23
25
  default: [
24
- :"blacklight.search.view.#{key}",
26
+ :"blacklight.search.view.#{deprecated_key || key}",
25
27
  label,
26
28
  title,
27
- key.to_s.humanize
28
- ]
29
+ (deprecated_key || key).to_s.humanize
30
+ ],
31
+ **options
29
32
  )
30
33
  end
31
34
 
@@ -38,6 +41,10 @@ class Blacklight::Configuration
38
41
  def document_presenter_class
39
42
  super || Blacklight::ShowPresenter
40
43
  end
44
+
45
+ def to_h
46
+ super.merge(document_presenter_class: document_presenter_class)
47
+ end
41
48
  end
42
49
 
43
50
  class Index < ViewConfig
@@ -52,6 +59,10 @@ class Blacklight::Configuration
52
59
  def document_presenter_class
53
60
  super || Blacklight::IndexPresenter
54
61
  end
62
+
63
+ def to_h
64
+ super.merge(document_presenter_class: document_presenter_class)
65
+ end
55
66
  end
56
67
  end
57
68
  end
@@ -8,7 +8,9 @@ module Blacklight
8
8
  # BlacklightHelper is needed by all helpers, so we inject it
9
9
  # into action view base here.
10
10
  initializer 'blacklight.helpers' do
11
- ActionView::Base.include BlacklightHelper
11
+ config.after_initialize do
12
+ ActionView::Base.include BlacklightHelper
13
+ end
12
14
  end
13
15
 
14
16
  # This makes our rake tasks visible.
@@ -4,7 +4,9 @@ module Blacklight
4
4
  ##
5
5
  # An OpenStruct that responds to common Hash methods
6
6
  class OpenStructWithHashAccess < OpenStruct
7
- delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?, :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!, :replace, :fetch, :to_json, :as_json, :any?, to: :to_h
7
+ delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?,
8
+ :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!,
9
+ :replace, :fetch, :to_json, :as_json, :any?, to: :to_h
8
10
 
9
11
  ##
10
12
  # Expose the internal hash
@@ -42,8 +44,27 @@ module Blacklight
42
44
  @table.merge!((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
43
45
  end
44
46
 
47
+ def reverse_merge(other_hash)
48
+ self.class.new to_h.reverse_merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
49
+ end
50
+
45
51
  def deep_dup
46
52
  self.class.new @table.deep_dup
47
53
  end
54
+
55
+ if Rails.version < '6'
56
+ # Ported from Rails 6 to fix an incompatibility with ostruct
57
+ def try(method_name = nil, *args, &block)
58
+ if method_name.nil? && block_given?
59
+ if b.arity.zero?
60
+ instance_eval(&block)
61
+ else
62
+ yield self
63
+ end
64
+ elsif respond_to?(method_name)
65
+ public_send(method_name, *args, &b)
66
+ end
67
+ end
68
+ end
48
69
  end
49
70
  end
@@ -8,6 +8,7 @@ module Blacklight
8
8
 
9
9
  def call(mapper, _options = {})
10
10
  mapper.match '/', action: 'index', as: 'search', via: [:get, :post]
11
+ mapper.get '/advanced', action: 'advanced_search', as: 'advanced_search'
11
12
 
12
13
  mapper.post ":id/track", action: 'track', as: 'track'
13
14
  mapper.get ":id/raw", action: 'raw', as: 'raw', defaults: { format: 'json' }
@@ -28,6 +28,7 @@ module Blacklight
28
28
 
29
29
  @blacklight_params = {}
30
30
  @search_state = Blacklight::SearchState.new(@blacklight_params, @scope&.blacklight_config, @scope)
31
+ @additional_filters = {}
31
32
  @merged_params = {}
32
33
  @reverse_merged_params = {}
33
34
  end
@@ -47,6 +48,7 @@ module Blacklight
47
48
  params_will_change!
48
49
  @search_state = @search_state.reset(@search_state.params.merge(q: conditions))
49
50
  @blacklight_params = @search_state.params.dup
51
+ @additional_filters = conditions
50
52
  self
51
53
  end
52
54
 
@@ -82,7 +82,7 @@ module Blacklight
82
82
 
83
83
  def has_constraints?
84
84
  Deprecation.silence(Blacklight::SearchState) do
85
- !(query_param.blank? && filter_params.blank? && filters.blank?)
85
+ !(query_param.blank? && filter_params.blank? && filters.blank? && clause_params.blank?)
86
86
  end
87
87
  end
88
88
 
@@ -90,6 +90,10 @@ module Blacklight
90
90
  params[:q]
91
91
  end
92
92
 
93
+ def clause_params
94
+ params[:clause] || {}
95
+ end
96
+
93
97
  def filter_params
94
98
  params[:f] || {}
95
99
  end
@@ -111,9 +115,9 @@ module Blacklight
111
115
  # documents
112
116
  def url_for_document(doc, options = {})
113
117
  if respond_to?(:blacklight_config) &&
114
- blacklight_config.show.route &&
118
+ blacklight_config.view_config(:show).route &&
115
119
  (!doc.respond_to?(:to_model) || doc.to_model.is_a?(SolrDocument))
116
- route = blacklight_config.show.route.merge(action: :show, id: doc).merge(options)
120
+ route = blacklight_config.view_config(:show).route.merge(action: :show, id: doc).merge(options)
117
121
  route[:controller] = params[:controller] if route[:controller] == :current
118
122
  route
119
123
  else
@@ -36,12 +36,16 @@ module Blacklight
36
36
  end
37
37
 
38
38
  params = new_state.params
39
+ param = :f
39
40
  value = as_url_parameter(item)
41
+ param = :f_inclusive if value.is_a?(Array)
40
42
 
41
43
  # value could be a string
42
44
  params[param] = (params[param] || {}).dup
43
45
 
44
- if config.single
46
+ if value.is_a? Array
47
+ params[param][key] = value
48
+ elsif config.single
45
49
  params[param][key] = [value]
46
50
  else
47
51
  params[param][key] = Array(params[param][key] || []).dup
@@ -60,7 +64,10 @@ module Blacklight
60
64
  end
61
65
 
62
66
  params = new_state.params
67
+
68
+ param = :f
63
69
  value = as_url_parameter(item)
70
+ param = :f_inclusive if value.is_a?(Array)
64
71
 
65
72
  # need to dup the facet values too,
66
73
  # if the values aren't dup'd, then the values
@@ -86,7 +93,10 @@ module Blacklight
86
93
  # @return [Array] an array of applied filters
87
94
  def values
88
95
  params = search_state.params
89
- Array(params.dig(param, key)) || []
96
+ f = Array(params.dig(:f, key))
97
+ f_inclusive = [params.dig(:f_inclusive, key)] if params.dig(:f_inclusive, key).present?
98
+
99
+ f + (f_inclusive || [])
90
100
  end
91
101
  delegate :any?, to: :values
92
102
 
@@ -100,15 +110,15 @@ module Blacklight
100
110
  value = as_url_parameter(item)
101
111
  params = search_state.params
102
112
 
103
- (params.dig(param, key) || []).include?(value)
113
+ if value.is_a?(Array)
114
+ (params.dig(:f_inclusive, key) || []).to_set == value.to_set
115
+ else
116
+ (params.dig(:f, key) || []).include?(value)
117
+ end
104
118
  end
105
119
 
106
120
  private
107
121
 
108
- def param
109
- :f
110
- end
111
-
112
122
  # TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
113
123
  def as_url_parameter(item)
114
124
  if item.respond_to? :value
@@ -20,6 +20,8 @@ module Blacklight::Solr
20
20
  def initialize(all_facet_values, arguments = {})
21
21
  super
22
22
 
23
+ @sort = arguments[:sort].keys.first.to_s if arguments[:sort].is_a? Hash
24
+
23
25
  # count is solr's default
24
26
  @sort ||= if @limit.to_i > 0
25
27
  'count'
@@ -58,8 +58,17 @@ module Blacklight::Solr
58
58
  # @return [Blacklight::Solr::Response] the solr response object
59
59
  def send_and_receive(path, solr_params = {})
60
60
  benchmark("Solr fetch", level: :debug) do
61
- key = blacklight_config.http_method == :post ? :data : :params
62
- res = connection.send_and_receive(path, { key => solr_params.to_hash, method: blacklight_config.http_method })
61
+ res = if solr_params[:json].present?
62
+ connection.send_and_receive(
63
+ path,
64
+ data: { params: solr_params.to_hash.except(:json) }.merge(solr_params[:json]).to_json,
65
+ method: :post,
66
+ headers: { 'Content-Type' => 'application/json' }
67
+ )
68
+ else
69
+ key = blacklight_config.http_method == :post ? :data : :params
70
+ connection.send_and_receive(path, { key => solr_params.to_hash, method: blacklight_config.http_method })
71
+ end
63
72
 
64
73
  solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model, blacklight_config: blacklight_config)
65
74
 
@@ -17,6 +17,37 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
17
17
  end
18
18
  end
19
19
 
20
+ def append_query(query)
21
+ if self['q'] || dig(:json, :query, :bool)
22
+ self[:json] ||= { query: { bool: { must: [] } } }
23
+ self[:json][:query] ||= { bool: { must: [] } }
24
+ self[:json][:query][:bool][:must] << query
25
+
26
+ if self['q']
27
+ self[:json][:query][:bool][:must] << self['q']
28
+ delete 'q'
29
+ end
30
+ else
31
+ self['q'] = query
32
+ end
33
+ end
34
+
35
+ def append_boolean_query(bool_operator, query)
36
+ return if query.blank?
37
+
38
+ self[:json] ||= { query: { bool: { bool_operator => [] } } }
39
+ self[:json][:query] ||= { bool: { bool_operator => [] } }
40
+ self[:json][:query][:bool][bool_operator] ||= []
41
+
42
+ if self['q']
43
+ self[:json][:query][:bool][:must] ||= []
44
+ self[:json][:query][:bool][:must] << self['q']
45
+ delete 'q'
46
+ end
47
+
48
+ self[:json][:query][:bool][bool_operator] << query
49
+ end
50
+
20
51
  def append_filter_query(query)
21
52
  self['fq'] << query
22
53
  end
@@ -9,6 +9,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
9
9
  autoload :MoreLikeThis
10
10
  autoload :GroupResponse
11
11
  autoload :Group
12
+ autoload :Params
12
13
  end
13
14
 
14
15
  include PaginationMethods
@@ -16,6 +17,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
16
17
  include Facets
17
18
  include Response
18
19
  include MoreLikeThis
20
+ include Params
19
21
 
20
22
  attr_reader :request_params
21
23
  attr_accessor :blacklight_config, :options
@@ -33,22 +35,6 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
33
35
  self['responseHeader'] || {}
34
36
  end
35
37
 
36
- def params
37
- header['params'] || request_params
38
- end
39
-
40
- def start
41
- params[:start].to_i
42
- end
43
-
44
- def rows
45
- params[:rows].to_i
46
- end
47
-
48
- def sort
49
- params[:sort]
50
- end
51
-
52
38
  def documents
53
39
  @documents ||= (response['docs'] || []).collect { |doc| document_factory.build(doc, self, options) }
54
40
  end