blacklight 5.9.4 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
  5. data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
  6. data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
  7. data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
  8. data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
  9. data/app/models/bookmark.rb +1 -4
  10. data/app/models/search.rb +3 -6
  11. data/app/views/catalog/_facet_layout.html.erb +2 -2
  12. data/app/views/catalog/_facet_limit.html.erb +5 -3
  13. data/app/views/catalog/_facet_pivot.html.erb +4 -4
  14. data/app/views/catalog/_home_text.html.erb +8 -48
  15. data/app/views/catalog/_index_default.html.erb +3 -3
  16. data/app/views/catalog/_show_default.html.erb +3 -3
  17. data/app/views/catalog/_sms_form.html.erb +1 -1
  18. data/app/views/catalog/facet.html.erb +1 -1
  19. data/blacklight.gemspec +1 -1
  20. data/config/jetty.yml +0 -3
  21. data/config/locales/blacklight.de.yml +2 -0
  22. data/config/locales/blacklight.en.yml +2 -0
  23. data/config/locales/blacklight.es.yml +2 -0
  24. data/config/locales/blacklight.fr.yml +2 -0
  25. data/config/locales/blacklight.pt-BR.yml +2 -0
  26. data/lib/blacklight.rb +70 -26
  27. data/lib/blacklight/abstract_repository.rb +29 -0
  28. data/lib/blacklight/base.rb +7 -7
  29. data/lib/blacklight/bookmarks.rb +5 -5
  30. data/lib/blacklight/catalog.rb +34 -19
  31. data/lib/blacklight/catalog/search_context.rb +1 -1
  32. data/lib/blacklight/configuration.rb +112 -46
  33. data/lib/blacklight/configuration/facet_field.rb +9 -7
  34. data/lib/blacklight/configuration/field.rb +27 -0
  35. data/lib/blacklight/configuration/fields.rb +25 -20
  36. data/lib/blacklight/configuration/search_field.rb +6 -8
  37. data/lib/blacklight/configuration/solr_field.rb +3 -18
  38. data/lib/blacklight/configuration/sort_field.rb +6 -7
  39. data/lib/blacklight/document.rb +156 -0
  40. data/lib/blacklight/document/dublin_core.rb +41 -0
  41. data/lib/blacklight/document/email.rb +16 -0
  42. data/lib/blacklight/document/export.rb +107 -0
  43. data/lib/blacklight/document/extensions.rb +56 -0
  44. data/lib/blacklight/document/schema_org.rb +7 -0
  45. data/lib/blacklight/document/semantic_fields.rb +51 -0
  46. data/lib/blacklight/document/sms.rb +14 -0
  47. data/lib/blacklight/document_presenter.rb +3 -3
  48. data/lib/blacklight/exceptions.rb +9 -2
  49. data/lib/blacklight/facet.rb +21 -16
  50. data/lib/blacklight/request_builders.rb +60 -284
  51. data/lib/blacklight/routes.rb +1 -1
  52. data/lib/blacklight/search_builder.rb +130 -0
  53. data/lib/blacklight/search_helper.rb +316 -0
  54. data/lib/blacklight/solr.rb +1 -0
  55. data/lib/blacklight/solr/document.rb +4 -187
  56. data/lib/blacklight/solr/document/dublin_core.rb +3 -37
  57. data/lib/blacklight/solr/document/email.rb +4 -13
  58. data/lib/blacklight/solr/document/export.rb +3 -103
  59. data/lib/blacklight/solr/document/extensions.rb +4 -52
  60. data/lib/blacklight/solr/document/more_like_this.rb +1 -1
  61. data/lib/blacklight/solr/document/schema_org.rb +4 -4
  62. data/lib/blacklight/solr/document/sms.rb +4 -11
  63. data/lib/blacklight/solr/facet_paginator.rb +2 -2
  64. data/lib/blacklight/solr/search_builder.rb +264 -0
  65. data/lib/blacklight/solr_helper.rb +6 -261
  66. data/lib/blacklight/solr_repository.rb +30 -24
  67. data/lib/blacklight/solr_response.rb +3 -3
  68. data/lib/blacklight/user.rb +1 -2
  69. data/lib/blacklight/utils.rb +0 -23
  70. data/lib/generators/blacklight/controller_generator.rb +38 -0
  71. data/lib/generators/blacklight/document_generator.rb +20 -0
  72. data/lib/generators/blacklight/install_generator.rb +38 -39
  73. data/lib/generators/blacklight/models_generator.rb +2 -62
  74. data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
  75. data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
  76. data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
  77. data/lib/generators/blacklight/templates/solr_document.rb +6 -6
  78. data/lib/generators/blacklight/test_support_generator.rb +1 -6
  79. data/lib/generators/blacklight/user_generator.rb +59 -0
  80. data/lib/railties/blacklight.rake +16 -7
  81. data/spec/controllers/catalog_controller_spec.rb +9 -15
  82. data/spec/features/facets_spec.rb +8 -0
  83. data/spec/helpers/configuration_helper_spec.rb +6 -13
  84. data/spec/helpers/facets_helper_spec.rb +3 -2
  85. data/spec/lib/blacklight/configuration_spec.rb +11 -38
  86. data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
  87. data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
  88. data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
  89. data/spec/lib/blacklight/search_builder_spec.rb +145 -0
  90. data/spec/lib/blacklight/search_helper_spec.rb +775 -0
  91. data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
  92. data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
  93. data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
  94. data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
  95. data/spec/models/record_mailer_spec.rb +2 -2
  96. data/spec/spec_helper.rb +1 -0
  97. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  98. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
  99. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
  100. data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
  101. data/tasks/blacklight.rake +1 -1
  102. data/template.demo.rb +1 -1
  103. metadata +33 -45
  104. data/doc/Adding-new-document-actions.md +0 -94
  105. data/doc/Atom-Responses.md +0 -90
  106. data/doc/Blacklight-Add-ons.md +0 -23
  107. data/doc/Blacklight-configuration.md +0 -411
  108. data/doc/Blacklight-on-Heroku.md +0 -100
  109. data/doc/Blacklight-out-of-the-box.md +0 -47
  110. data/doc/Bookmarks.md +0 -1
  111. data/doc/Code4Lib-2014.md +0 -94
  112. data/doc/Configuration---Facet-Fields.md +0 -130
  113. data/doc/Configuration---Results-View.md +0 -224
  114. data/doc/Configuration---Solr-fields.md +0 -106
  115. data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
  116. data/doc/Configuring-rails-routes.md +0 -13
  117. data/doc/Contributing-to-Blacklight.md +0 -43
  118. data/doc/Examples.md +0 -120
  119. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
  120. data/doc/Home.md +0 -100
  121. data/doc/How-to-release-a-version.md +0 -45
  122. data/doc/Indexing-your-data-into-solr.md +0 -36
  123. data/doc/Internationalization.md +0 -32
  124. data/doc/JSON-API.md +0 -83
  125. data/doc/Pagination.md +0 -52
  126. data/doc/Providing-your-own-view-templates.md +0 -69
  127. data/doc/Quickstart.md +0 -153
  128. data/doc/README_SOLR.md +0 -245
  129. data/doc/Saved-Searches.md +0 -5
  130. data/doc/Solr-Configuration.md +0 -154
  131. data/doc/Sunspot-for-indexing.md +0 -46
  132. data/doc/Support.md +0 -33
  133. data/doc/Theming.md +0 -62
  134. data/doc/Understanding-Rails-and-Blacklight.md +0 -75
  135. data/doc/User-Authentication.md +0 -60
  136. data/doc/_Sidebar.md +0 -9
  137. data/doc/testing.md +0 -58
@@ -94,9 +94,9 @@ module Blacklight
94
94
  end
95
95
 
96
96
  def catalog(_=nil)
97
- Deprecation.warn(Blacklight::Routes, "Blacklight::Routes.catalog is deprecated and will be removed in Blacklight 6.0. Use Blacklight::Routes.map_resource(:catalog) instead.")
98
97
  map_resource(:catalog)
99
98
  end
99
+ deprecation_deprecate catalog: "use Blacklight::Routes.map_resource(:catalog) instead"
100
100
 
101
101
  def map_resource(key)
102
102
  add_routes do |options|
@@ -0,0 +1,130 @@
1
+ module Blacklight
2
+ class SearchBuilder
3
+ extend Deprecation
4
+ self.deprecation_horizon = "blacklight 6.0"
5
+
6
+ attr_reader :processor_chain, :blacklight_params
7
+
8
+ # @param [List<Symbol>] processor_chain a list of filter methods to run
9
+ # @param [Object] scope the scope where the filter methods reside in.
10
+ def initialize(processor_chain, scope)
11
+ @processor_chain = processor_chain
12
+ @scope = scope
13
+ @blacklight_params = {}
14
+ end
15
+
16
+ ##
17
+ # Set the parameters to pass through the processor chain
18
+ def with blacklight_params = {}
19
+ @blacklight_params = blacklight_params.dup
20
+ self
21
+ end
22
+
23
+ ##
24
+ # Update the :q (query) parameter
25
+ def where conditions
26
+ @blacklight_params[:q] = conditions
27
+ self
28
+ end
29
+
30
+ ##
31
+ # Append additional processor chain directives
32
+ def append *addl_processor_chain
33
+ self.class.new(processor_chain + addl_processor_chain, scope).with(blacklight_params)
34
+ end
35
+
36
+ # a solr query method
37
+ # @param [Hash,HashWithIndifferentAccess] extra_controller_params (nil) extra parameters to add to the search
38
+ # @return [Blacklight::SolrResponse] the solr response object
39
+ def query(extra_params = nil)
40
+ extra_params ? processed_parameters.merge(extra_params) : processed_parameters
41
+ end
42
+
43
+ # @returns a params hash for searching solr.
44
+ # The CatalogController #index action uses this.
45
+ # Solr parameters can come from a number of places. From lowest
46
+ # precedence to highest:
47
+ # 1. General defaults in blacklight config (are trumped by)
48
+ # 2. defaults for the particular search field identified by params[:search_field] (are trumped by)
49
+ # 3. certain parameters directly on input HTTP query params
50
+ # * not just any parameter is grabbed willy nilly, only certain ones are allowed by HTTP input)
51
+ # * for legacy reasons, qt in http query does not over-ride qt in search field definition default.
52
+ # 4. extra parameters passed in as argument.
53
+ #
54
+ # spellcheck.q will be supplied with the [:q] value unless specifically
55
+ # specified otherwise.
56
+ #
57
+ # Incoming parameter :f is mapped to :fq solr parameter.
58
+ def processed_parameters
59
+ Blacklight::Solr::Request.new.tap do |request_parameters|
60
+ @processor_chain.each do |method_name|
61
+ if scope.respond_to?(method_name, true)
62
+ Deprecation.warn Blacklight::SearchBuilder, "Building search parameters by calling #{method_name} on #{scope.class}. This behavior will be deprecated in Blacklight 6.0. Instead, define #{method_name} on a subclass of #{self.class} and set search_builder_class in the configuration"
63
+ scope.send(method_name, request_parameters, blacklight_params)
64
+ else
65
+ send(method_name, request_parameters)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ def blacklight_config
72
+ scope.blacklight_config
73
+ end
74
+
75
+ protected
76
+ def page
77
+ if blacklight_params[:page].blank?
78
+ 1
79
+ else
80
+ blacklight_params[:page].to_i
81
+ end
82
+ end
83
+
84
+ def rows default = nil
85
+ # default number of rows
86
+ rows = default
87
+ rows ||= blacklight_config.default_per_page
88
+ rows ||= 10
89
+
90
+ # user-provided parameters should override any default row
91
+ rows = blacklight_params[:rows].to_i unless blacklight_params[:rows].blank?
92
+ rows = blacklight_params[:per_page].to_i unless blacklight_params[:per_page].blank?
93
+
94
+ # ensure we don't excede the max page size
95
+ rows = blacklight_config.max_per_page if rows.to_i > blacklight_config.max_per_page
96
+
97
+
98
+ rows
99
+ end
100
+
101
+ def sort
102
+ field = if blacklight_params[:sort].blank? and sort_field = blacklight_config.default_sort_field
103
+ # no sort param provided, use default
104
+ sort_field.sort
105
+ elsif sort_field = blacklight_config.sort_fields[blacklight_params[:sort]]
106
+ # check for sort field key
107
+ sort_field.sort
108
+ else
109
+ # just pass the key through
110
+ blacklight_params[:sort]
111
+ end
112
+
113
+ field unless field.blank?
114
+ end
115
+
116
+ def search_field
117
+ blacklight_config.search_fields[blacklight_params[:search_field]]
118
+ end
119
+
120
+ def should_add_field_to_request? field_name, field
121
+ field.include_in_request || (field.include_in_request.nil? && blacklight_config.add_field_configuration_to_solr_request)
122
+ end
123
+
124
+ protected
125
+ def scope
126
+ @scope
127
+ end
128
+
129
+ end
130
+ end
@@ -0,0 +1,316 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # SearchHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
3
+ #
4
+ # NOTE: Be careful when creating variables here as they may be overriding something that already exists.
5
+ # The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
6
+ #
7
+ # Override these methods in your own controller for customizations:
8
+ #
9
+ # class CatalogController < ActionController::Base
10
+ #
11
+ # include Blacklight::Catalog
12
+ #
13
+ # def repository_class
14
+ # MyAlternativeRepo
15
+ # end
16
+ # end
17
+ #
18
+ # Or by including in local extensions:
19
+ # module LocalSearchHelperExtension
20
+ # [ local overrides ]
21
+ # end
22
+ #
23
+ # class CatalogController < ActionController::Base
24
+ #
25
+ # include Blacklight::Catalog
26
+ # include LocalSearchHelperExtension
27
+ #
28
+ # def repository_class
29
+ # MyAlternativeRepo
30
+ # end
31
+ # end
32
+ #
33
+ # Or by using ActiveSupport::Concern:
34
+ #
35
+ # module LocalSearchHelperExtension
36
+ # extend ActiveSupport::Concern
37
+ # include Blacklight::SearchHelper
38
+ #
39
+ # [ local overrides ]
40
+ # end
41
+ #
42
+ # class CatalogController < ApplicationController
43
+ # include LocalSearchHelperExtension
44
+ # include Blacklight::Catalog
45
+ # end
46
+
47
+ module Blacklight::SearchHelper
48
+ extend ActiveSupport::Concern
49
+ extend Deprecation
50
+ self.deprecation_horizon = 'blacklight 6.0'
51
+
52
+ include Blacklight::RequestBuilders
53
+
54
+ ##
55
+ # Execute a solr query
56
+ # @see [Blacklight::SolrRepository#send_and_receive]
57
+ # @return [Blacklight::SolrResponse] the solr response object
58
+ def find *args
59
+ request_params = args.extract_options!
60
+ path = args.first || blacklight_config.solr_path
61
+
62
+ request_params[:qt] ||= blacklight_config.qt
63
+
64
+ repository.send_and_receive path, request_params
65
+ end
66
+ deprecation_deprecate :find
67
+
68
+ # returns a params hash for finding a single solr document (CatalogController #show action)
69
+ def solr_doc_params(id=nil)
70
+ default_solr_doc_params(id)
71
+ end
72
+ deprecation_deprecate :solr_doc_params
73
+
74
+ # a solr query method
75
+ # given a user query, return a solr response containing both result docs and facets
76
+ # - mixes in the Blacklight::Solr::SpellingSuggestions module
77
+ # - the response will have a spelling_suggestions method
78
+ # Returns a two-element array (aka duple) with first the solr response object,
79
+ # and second an array of SolrDocuments representing the response.docs
80
+ def get_search_results(user_params = params || {}, extra_controller_params = {})
81
+ query = search_builder.with(user_params).query(extra_controller_params)
82
+ response = repository.search(query)
83
+
84
+ case
85
+ when (response.grouped? && grouped_key_for_results)
86
+ [response.group(grouped_key_for_results), []]
87
+ when (response.grouped? && response.grouped.length == 1)
88
+ [response.grouped.first, []]
89
+ else
90
+ [response, response.documents]
91
+ end
92
+ end
93
+ deprecation_deprecate get_search_results: :search_results
94
+
95
+ # a solr query method
96
+ # @param [Hash,HashWithIndifferentAccess] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
97
+ # @param [Hash,HashWithIndifferentAccess] extra_controller_params ({}) extra parameters to add to the search
98
+ # @param [List<Symbol] processor_chain a list of filter methods to run
99
+ # @return [Blacklight::SolrResponse] the solr response object
100
+ def search_results(user_params, search_params_logic)
101
+ query = search_builder(search_params_logic).with(user_params).query
102
+ response = repository.search(query)
103
+
104
+ case
105
+ when (response.grouped? && grouped_key_for_results)
106
+ [response.group(grouped_key_for_results), []]
107
+ when (response.grouped? && response.grouped.length == 1)
108
+ [response.grouped.first, []]
109
+ else
110
+ [response, response.documents]
111
+ end
112
+ end
113
+
114
+ # a solr query method
115
+ # @param [Hash,HashWithIndifferentAccess] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
116
+ # @param [Hash,HashWithIndifferentAccess] extra_controller_params ({}) extra parameters to add to the search
117
+ # @return [Blacklight::SolrResponse] the solr response object
118
+ def query_solr(user_params = params || {}, extra_controller_params = {})
119
+ query = search_builder.with(user_params).query(extra_controller_params)
120
+ repository.search(query)
121
+ end
122
+ deprecation_deprecate :query_solr
123
+
124
+ # retrieve a document, given the doc id
125
+ # @return [Blacklight::SolrResponse, Blacklight::SolrDocument] the solr response object and the first document
126
+ def fetch(id=nil, extra_controller_params={})
127
+ if id.is_a? Array
128
+ fetch_many(id, params, extra_controller_params)
129
+ else
130
+ if id.nil?
131
+ Deprecation.warn Blacklight::SearchHelper, "Calling #fetch without an explicit id argument is deprecated and will be removed in Blacklight 6.0"
132
+ id ||= params[:id]
133
+ end
134
+ fetch_one(id, extra_controller_params)
135
+ end
136
+ end
137
+
138
+ alias_method :get_solr_response_for_doc_id, :fetch
139
+ deprecation_deprecate get_solr_response_for_doc_id: "use fetch(id) instead"
140
+
141
+ # given a field name and array of values, get the matching SOLR documents
142
+ # @return [Blacklight::SolrResponse, Array<Blacklight::SolrDocument>] the solr response object and a list of solr documents
143
+ def get_solr_response_for_field_values(field, values, extra_controller_params = {})
144
+ query = Deprecation.silence(Blacklight::RequestBuilders) do
145
+ search_builder.with(params).query(extra_controller_params.merge(solr_documents_by_field_values_params(field, values)))
146
+ end
147
+
148
+ solr_response = repository.search(query)
149
+
150
+
151
+ [solr_response, solr_response.documents]
152
+ end
153
+ deprecation_deprecate :get_solr_response_for_field_values
154
+
155
+ ##
156
+ # Get the solr response when retrieving only a single facet field
157
+ # @return [Blacklight::SolrResponse] the solr response
158
+ def get_facet_field_response(facet_field, user_params = params || {}, extra_controller_params = {})
159
+ query = search_builder.with(user_params).query(extra_controller_params.merge(solr_facet_params(facet_field, user_params, extra_controller_params)))
160
+ repository.search(query)
161
+ end
162
+
163
+ # a solr query method
164
+ # used to paginate through a single facet field's values
165
+ # /catalog/facet/language_facet
166
+ def get_facet_pagination(facet_field, user_params=params || {}, extra_controller_params={})
167
+ # Make the solr call
168
+ response = get_facet_field_response(facet_field, user_params, extra_controller_params)
169
+
170
+ limit = response.params[:"f.#{facet_field}.facet.limit"].to_s.to_i - 1
171
+
172
+ # Actually create the paginator!
173
+ # NOTE: The sniffing of the proper sort from the solr response is not
174
+ # currently tested for, tricky to figure out how to test, since the
175
+ # default setup we test against doesn't use this feature.
176
+ Blacklight::Solr::FacetPaginator.new(response.facets.first.items,
177
+ :offset => response.params[:"f.#{facet_field}.facet.offset"],
178
+ :limit => limit,
179
+ :sort => response.params[:"f.#{facet_field}.facet.sort"] || response.params["facet.sort"]
180
+ )
181
+ end
182
+ deprecation_deprecate :get_facet_pagination
183
+
184
+ # a solr query method
185
+ # this is used when selecting a search result: we have a query and a
186
+ # position in the search results and possibly some facets
187
+ # Pass in an index where 1 is the first document in the list, and
188
+ # the Blacklight app-level request params that define the search.
189
+ # @return [Blacklight::SolrDocument, nil] the found document or nil if not found
190
+ def get_single_doc_via_search(index, request_params)
191
+ request_params = search_builder.with(request_params).processed_parameters
192
+
193
+ request_params[:start] = (index - 1) # start at 0 to get 1st doc, 1 to get 2nd.
194
+ request_params[:rows] = 1
195
+ request_params[:fl] = '*'
196
+ response = repository.search(request_params)
197
+ response.documents.first
198
+ end
199
+ deprecation_deprecate :get_single_doc_via_search
200
+
201
+ # Get the previous and next document from a search result
202
+ # @return [Blacklight::SolrResponse, Array<Blacklight::SolrDocument>] the solr response and a list of the first and last document
203
+ def get_previous_and_next_documents_for_search(index, request_params, extra_controller_params={})
204
+
205
+ query = search_builder.with(request_params).query(extra_controller_params.merge(previous_and_next_document_params(index)))
206
+ response = repository.search(query)
207
+
208
+ document_list = response.documents
209
+
210
+ # only get the previous doc if there is one
211
+ prev_doc = document_list.first if index > 0
212
+ next_doc = document_list.last if (index + 1) < response.total
213
+
214
+ [response, [prev_doc, next_doc]]
215
+ end
216
+
217
+ # a solr query method
218
+ # does a standard search but returns a simplified object.
219
+ # an array is returned, the first item is the query string,
220
+ # the second item is an other array. This second array contains
221
+ # all of the field values for each of the documents...
222
+ # where the field is the "field" argument passed in.
223
+ def get_opensearch_response(field=nil, request_params = params || {}, extra_controller_params={})
224
+ field ||= blacklight_config.view_config('opensearch').title_field
225
+
226
+ query = search_builder.with(request_params).query(solr_opensearch_params(field).merge(extra_controller_params))
227
+ response = repository.search(query)
228
+
229
+ [response.params[:q], response.documents.flat_map {|doc| doc[field] }.uniq]
230
+ end
231
+
232
+ ##
233
+ # The key to use to retrieve the grouped field to display
234
+ def grouped_key_for_results
235
+ blacklight_config.index.group
236
+ end
237
+
238
+ def repository_class
239
+ blacklight_config.repository_class
240
+ end
241
+
242
+ def repository
243
+ @repository ||= repository_class.new(blacklight_config)
244
+ end
245
+
246
+ def solr_repository
247
+ repository
248
+ end
249
+ deprecation_deprecate solr_repository: :repository
250
+
251
+ def blacklight_solr
252
+ repository.connection
253
+ end
254
+ deprecation_deprecate blacklight_solr: "use repository.connection instead"
255
+
256
+ private
257
+
258
+ ##
259
+ # Retrieve a set of documents by id
260
+ # @overload fetch_many(ids, extra_controller_params)
261
+ # @overload fetch_many(ids, user_params, extra_controller_params)
262
+ def fetch_many(ids=[], *args)
263
+ if args.length == 1
264
+ Deprecation.warn(Blacklight::SearchHelper, "fetch_many with 2 arguments is deprecated")
265
+ user_params = params
266
+ extra_controller_params = args.first || {}
267
+ else
268
+ user_params, extra_controller_params = args
269
+ user_params ||= params
270
+ extra_controller_params ||= {}
271
+ end
272
+
273
+ query = search_builder.
274
+ with(user_params).
275
+ where(blacklight_config.document_model.unique_key => ids).
276
+ query(extra_controller_params.merge(fl: '*'))
277
+ solr_response = repository.search(query)
278
+
279
+ [solr_response, solr_response.documents]
280
+ end
281
+
282
+ alias_method :get_solr_response_for_document_ids, :fetch_many
283
+ deprecation_deprecate get_solr_response_for_document_ids: "use fetch(ids) instead"
284
+
285
+ def fetch_one(id, extra_controller_params)
286
+ old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do
287
+ solr_doc_params(id)
288
+ end
289
+
290
+ if default_solr_doc_params(id) != old_solr_doc_params
291
+ Deprecation.warn Blacklight::SearchHelper, "The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0"
292
+ extra_controller_params = extra_controller_params.merge(old_solr_doc_params)
293
+ end
294
+
295
+ solr_response = repository.find id, extra_controller_params
296
+ [solr_response, solr_response.documents.first]
297
+ end
298
+
299
+ ##
300
+ # @deprecated
301
+ def default_solr_doc_params(id=nil)
302
+ id ||= params[:id]
303
+
304
+ # add our document id to the document_unique_id_param query parameter
305
+ p = blacklight_config.default_document_solr_params.merge({
306
+ # this assumes the request handler will map the unique id param
307
+ # to the unique key field using either solr local params, the
308
+ # real-time get handler, etc.
309
+ blacklight_config.document_unique_id_param => id
310
+ })
311
+
312
+ p[:qt] ||= blacklight_config.document_solr_request_handler
313
+
314
+ p
315
+ end
316
+ end