blacklight_oai_provider 5.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.solr_wrapper +1 -1
- data/.travis.yml +21 -11
- data/Gemfile +3 -0
- data/README.md +12 -20
- data/Rakefile +0 -2
- data/VERSION +1 -1
- data/app/controllers/concerns/blacklight_oai_provider/controller.rb +8 -3
- data/app/models/concerns/blacklight_oai_provider/solr_document.rb +1 -1
- data/blacklight_oai_provider.gemspec +5 -11
- data/lib/blacklight_oai_provider.rb +0 -14
- data/lib/blacklight_oai_provider/engine.rb +0 -9
- data/lib/blacklight_oai_provider/routes.rb +5 -9
- data/lib/blacklight_oai_provider/solr_document_provider.rb +3 -2
- data/lib/blacklight_oai_provider/solr_document_wrapper.rb +18 -18
- data/lib/blacklight_oai_provider/solr_set.rb +5 -3
- data/lib/generators/blacklight_oai_provider/install_generator.rb +12 -0
- data/lib/railties/blacklight_oai_provider.rake +1 -1
- data/solr/conf/schema.xml +322 -563
- data/solr/conf/solrconfig.xml +55 -182
- data/solr/sample_solr_documents.yml +722 -722
- data/spec/controllers/catalog_controller_spec.rb +0 -1
- data/spec/lib/blacklight_oai_provider/solr_document_provider_spec.rb +50 -0
- data/spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb +1 -1
- data/spec/lib/blacklight_oai_provider/solr_set_spec.rb +7 -7
- data/spec/requests/get_record_spec.rb +10 -0
- data/spec/requests/list_identifiers_spec.rb +4 -4
- data/spec/requests/list_records_spec.rb +5 -5
- data/spec/requests/list_sets_spec.rb +7 -7
- data/spec/spec_helper.rb +2 -11
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -23
- data/spec/test_app_templates/templates/catalog_controller.rb +196 -0
- metadata +22 -52
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightOaiProvider::SolrDocumentProvider do
|
4
|
+
subject(:provider) { described_class.new(controller, options) }
|
5
|
+
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:controller) { CatalogController.new }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
let(:view_context) { instance_double("ViewContext") }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(controller).to receive(:view_context).and_return(view_context)
|
14
|
+
allow(view_context).to receive(:oai_catalog_url).and_return(:some_path)
|
15
|
+
allow(view_context).to receive(:application_name).and_return(:some_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with no options provided' do
|
19
|
+
it 'sets the default repository name and url' do
|
20
|
+
expect(provider.url).to eq :some_path
|
21
|
+
expect(provider.name).to eq :some_name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with options provided' do
|
26
|
+
let(:options) { { provider: { repository_url: '/my/custom/path', repository_name: 'My Custom Name' } } }
|
27
|
+
|
28
|
+
it 'uses the repository name and url set into the options' do
|
29
|
+
expect(provider.url).to eq '/my/custom/path'
|
30
|
+
expect(provider.name).to eq 'My Custom Name'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with Procs provided as option values' do
|
35
|
+
let(:options) do
|
36
|
+
{
|
37
|
+
provider: {
|
38
|
+
repository_name: ->(kontroller) { "Hello #{kontroller.__id__}" },
|
39
|
+
repository_url: ->(kontroller) { "Hello #{kontroller.view_context.oai_catalog_url}" }
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'call()-s the Proc to set the option value' do
|
45
|
+
expect(provider.name).to eq "Hello #{controller.__id__}"
|
46
|
+
expect(provider.url).to eq "Hello #{controller.view_context.oai_catalog_url}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -38,7 +38,7 @@ RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
|
|
38
38
|
|
39
39
|
describe '#latest' do
|
40
40
|
it 'returns the latest timestamp of all the records' do
|
41
|
-
expect(wrapper.latest).to eq Time.parse('
|
41
|
+
expect(wrapper.latest).to eq Time.parse('2015-02-03 18:42:53.056000000 +0000').utc
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe BlacklightOaiProvider::SolrSet do
|
4
4
|
let(:controller) { CatalogController.new }
|
5
5
|
let(:fields) do
|
6
|
-
[{ label: 'language', solr_field: '
|
6
|
+
[{ label: 'language', solr_field: 'language_ssim' }]
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
@@ -23,7 +23,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
23
23
|
context 'with multiple fields' do
|
24
24
|
let(:fields) do
|
25
25
|
[
|
26
|
-
{ label: 'language', solr_field: '
|
26
|
+
{ label: 'language', solr_field: 'language_ssim' },
|
27
27
|
{ solr_field: 'format' }
|
28
28
|
]
|
29
29
|
end
|
@@ -35,7 +35,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
35
35
|
|
36
36
|
context 'for a field with no values' do
|
37
37
|
let(:fields) do
|
38
|
-
[{ label: 'author', solr_field: '
|
38
|
+
[{ label: 'author', solr_field: 'author_ts' }]
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns nil' do
|
@@ -45,12 +45,12 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
45
45
|
|
46
46
|
context 'for a field with facet config limit' do
|
47
47
|
let(:fields) do
|
48
|
-
[{ label: 'lc_alpha', solr_field: '
|
48
|
+
[{ label: 'lc_alpha', solr_field: 'lc_alpha_ssim' }]
|
49
49
|
end
|
50
50
|
|
51
51
|
before do
|
52
52
|
CatalogController.configure_blacklight do |config|
|
53
|
-
config.add_facet_field '
|
53
|
+
config.add_facet_field 'lc_alpha_ssim', label: 'lc_alpha', limit: 2
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -65,7 +65,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
65
65
|
let(:spec) { 'language:Hebrew' }
|
66
66
|
|
67
67
|
it 'returns the filter query' do
|
68
|
-
expect(described_class.from_spec(spec)).to eq '
|
68
|
+
expect(described_class.from_spec(spec)).to eq 'language_ssim:"Hebrew"'
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -94,7 +94,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'gets solr field' do
|
97
|
-
expect(set.solr_field).to eql '
|
97
|
+
expect(set.solr_field).to eql 'language_ssim'
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -51,4 +51,14 @@ describe 'OIA-PMH GetRecord Request' do
|
|
51
51
|
it 'contains format' do
|
52
52
|
expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:format', namespaces).text).to eql 'Book'
|
53
53
|
end
|
54
|
+
|
55
|
+
context 'when identifier has slashes' do
|
56
|
+
before do
|
57
|
+
get '/catalog/oai?verb=GetRecord&identifier=oai:test:fe/gh/00313831&metadataPrefix=oai_dc'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'retrieves record' do
|
61
|
+
expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:identifier').text).to eql 'oai:test:fe/gh/00313831'
|
62
|
+
end
|
63
|
+
end
|
54
64
|
end
|
@@ -18,7 +18,7 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'contains resumptionToken' do
|
21
|
-
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(
|
21
|
+
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(2015-02-03T18:42:53Z).t(30):25'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,8 +27,8 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
27
27
|
get '/catalog/oai?verb=ListIdentifiers&resumptionToken=oai_dc.f(2014-02-03T18:42:53Z).u(2014-03-03T18:42:53Z).t(30):25'
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'returns
|
31
|
-
expect(xml.xpath('//xmlns:ListIdentifiers/xmlns:header').count).to be
|
30
|
+
it 'returns 4 records' do
|
31
|
+
expect(xml.xpath('//xmlns:ListIdentifiers/xmlns:header').count).to be 4
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'first record has identifier and timestamp' do
|
@@ -57,7 +57,7 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
57
57
|
|
58
58
|
context 'with different timestamp_field' do
|
59
59
|
before :all do
|
60
|
-
SolrDocument.timestamp_key = "
|
60
|
+
SolrDocument.timestamp_key = "record_creation_dtsi"
|
61
61
|
end
|
62
62
|
|
63
63
|
before do
|
@@ -24,7 +24,7 @@ describe 'OIA-PMH ListRecords Request' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'contains resumptionToken' do
|
27
|
-
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(
|
27
|
+
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(2015-02-03T18:42:53Z).t(30):25'
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'for record' do
|
@@ -73,8 +73,8 @@ describe 'OIA-PMH ListRecords Request' do
|
|
73
73
|
get '/catalog/oai?verb=ListRecords&resumptionToken=oai_dc.f(2014-02-03T18:42:53Z).u(2014-02-03T18:42:53Z).t(29):25'
|
74
74
|
end
|
75
75
|
|
76
|
-
it 'returns
|
77
|
-
expect(xml.xpath('//xmlns:ListRecords/xmlns:record/xmlns:header').count).to be
|
76
|
+
it 'returns 3 records' do
|
77
|
+
expect(xml.xpath('//xmlns:ListRecords/xmlns:record/xmlns:header').count).to be 3
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'first record has oai_dc metadata element' do
|
@@ -112,14 +112,14 @@ describe 'OIA-PMH ListRecords Request' do
|
|
112
112
|
it 'only records from the set are returned' do
|
113
113
|
params = { verb: 'ListRecords', metadataPrefix: 'oai_dc', set: 'language:Japanese' }
|
114
114
|
|
115
|
-
get
|
115
|
+
get oai_catalog_path(params)
|
116
116
|
expect(xml.xpath('//xmlns:record').count).to be 2
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context 'throws noRecordsMatch error' do
|
121
121
|
before do
|
122
|
-
get '/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc&from=
|
122
|
+
get '/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc&from=2016-01-01'
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'returns no records error' do
|
@@ -27,7 +27,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
27
27
|
|
28
28
|
context 'without set configuration' do
|
29
29
|
it 'shows that no sets exist' do
|
30
|
-
get
|
30
|
+
get oai_catalog_path(verb: 'ListSets')
|
31
31
|
expect(xml.xpath('//xmlns:error').text).to eql 'This repository does not support sets.'
|
32
32
|
end
|
33
33
|
end
|
@@ -36,18 +36,18 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
36
36
|
let(:test_oai_config) { old_config }
|
37
37
|
|
38
38
|
it 'shows all sets' do
|
39
|
-
get
|
39
|
+
get oai_catalog_path(verb: 'ListSets')
|
40
40
|
expect(xml.xpath('//xmlns:set').count).to be 12
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'contains english set' do
|
44
|
-
get
|
44
|
+
get oai_catalog_path(verb: 'ListSets')
|
45
45
|
expect(xml.xpath('//xmlns:set//xmlns:setSpec').map(&:text)).to include 'language:English'
|
46
46
|
expect(xml.xpath('//xmlns:set//xmlns:setName').map(&:text)).to include 'Language: English'
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'shows the correct verb' do
|
50
|
-
get
|
50
|
+
get oai_catalog_path(verb: 'ListSets')
|
51
51
|
expect(xml.at_xpath('//xmlns:request').attribute('verb').value).to eql 'ListSets'
|
52
52
|
end
|
53
53
|
end
|
@@ -57,7 +57,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
57
57
|
{
|
58
58
|
document: {
|
59
59
|
set_fields: [
|
60
|
-
{ label: 'subject', solr_field: '
|
60
|
+
{ label: 'subject', solr_field: 'subject_ssim',
|
61
61
|
description: "Subject topic set using FAST subjects" }
|
62
62
|
]
|
63
63
|
}
|
@@ -65,7 +65,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'shows set description' do
|
68
|
-
get
|
68
|
+
get oai_catalog_path(verb: 'ListSets')
|
69
69
|
expect(
|
70
70
|
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
71
71
|
).to eql 'Subject topic set using FAST subjects'
|
@@ -92,7 +92,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "shows correct description" do
|
95
|
-
get
|
95
|
+
get oai_catalog_path(verb: 'ListSets')
|
96
96
|
expect(
|
97
97
|
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
98
98
|
).to eql 'This is a format set containing records with the value of Book.'
|
data/spec/spec_helper.rb
CHANGED
@@ -6,18 +6,9 @@ EngineCart.load_application!
|
|
6
6
|
require 'rspec/rails'
|
7
7
|
require 'capybara/rspec'
|
8
8
|
require 'selenium-webdriver'
|
9
|
+
require 'webdrivers'
|
9
10
|
|
10
|
-
Capybara.javascript_driver = :
|
11
|
-
|
12
|
-
Capybara.register_driver :headless_chrome do |app|
|
13
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
14
|
-
chromeOptions: { args: %w[headless disable-gpu] }
|
15
|
-
)
|
16
|
-
|
17
|
-
Capybara::Selenium::Driver.new(app,
|
18
|
-
browser: :chrome,
|
19
|
-
desired_capabilities: capabilities)
|
20
|
-
end
|
11
|
+
Capybara.javascript_driver = :selenium_chrome_headless
|
21
12
|
|
22
13
|
RSpec.configure do |config|
|
23
14
|
config.infer_spec_type_from_file_location!
|
@@ -13,6 +13,17 @@ class TestAppGenerator < Rails::Generators::Base
|
|
13
13
|
generate 'blacklight:install', '--devise'
|
14
14
|
end
|
15
15
|
|
16
|
+
def change_migrations_if_rails_4_2
|
17
|
+
return unless Rails.version =~ /^4.2.*/
|
18
|
+
|
19
|
+
say_status('warning', 'OVERRIDING BLACKLIGHT MIGRATION FOR RAILS 4.2', :yellow)
|
20
|
+
migrations = Rails.root.join('db', 'migrate', '*.rb')
|
21
|
+
Dir.glob(migrations).each do |m|
|
22
|
+
text = File.read(m).gsub(/ActiveRecord::Migration\[[\d\.]+\]/, 'ActiveRecord::Migration')
|
23
|
+
File.open(m, 'w').write(text)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
# Add favicon.ico to asset path
|
17
28
|
# ADD THIS LINE Rails.application.config.assets.precompile += %w( favicon.ico )
|
18
29
|
# TO config/assets.rb
|
@@ -34,6 +45,10 @@ class TestAppGenerator < Rails::Generators::Base
|
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
48
|
+
def overwrite_catalog_controller
|
49
|
+
copy_file "templates/catalog_controller.rb", "app/controllers/catalog_controller.rb", force: true
|
50
|
+
end
|
51
|
+
|
37
52
|
def install_engine
|
38
53
|
say_status("warning", "GENERATING BL OAI PLUGIN", :yellow)
|
39
54
|
|
@@ -43,17 +58,17 @@ class TestAppGenerator < Rails::Generators::Base
|
|
43
58
|
def add_test_blacklight_oai_config
|
44
59
|
say_status("warning", "ADDING BL OIA-PMH CONFIG")
|
45
60
|
|
46
|
-
insert_into_file "app/controllers/catalog_controller.rb", after: "
|
47
|
-
" :
|
61
|
+
insert_into_file "app/controllers/catalog_controller.rb", after: "config.default_solr_params = {" do
|
62
|
+
"\n fl: '*',\n"
|
48
63
|
end
|
49
64
|
|
50
65
|
insert_into_file "app/controllers/catalog_controller.rb", after: " configure_blacklight do |config|\n" do
|
51
66
|
<<-CONFIG
|
52
67
|
config.default_document_solr_params = {
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
68
|
+
qt: 'search',
|
69
|
+
fl: '*',
|
70
|
+
rows: 1,
|
71
|
+
q: '{!raw f=id v=$id}'
|
57
72
|
}
|
58
73
|
CONFIG
|
59
74
|
end
|
@@ -61,20 +76,19 @@ class TestAppGenerator < Rails::Generators::Base
|
|
61
76
|
insert_into_file "app/controllers/catalog_controller.rb", after: "configure_blacklight do |config|\n" do
|
62
77
|
<<-CONFIG
|
63
78
|
config.oai = {
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
79
|
+
provider: {
|
80
|
+
repository_name: 'Test Repository',
|
81
|
+
repository_url: 'http://localhost/catalog/oai',
|
82
|
+
record_prefix: 'oai:test',
|
83
|
+
admin_email: 'root@localhost',
|
84
|
+
deletion_support: 'persistent',
|
85
|
+
sample_id: '109660'
|
71
86
|
},
|
72
|
-
:
|
73
|
-
:
|
74
|
-
|
75
|
-
{ label: 'language', solr_field: 'language_facet' }
|
87
|
+
document: {
|
88
|
+
set_fields: [
|
89
|
+
{ label: 'language', solr_field: 'language_ssim' }
|
76
90
|
],
|
77
|
-
:
|
91
|
+
limit: 25
|
78
92
|
}
|
79
93
|
}
|
80
94
|
CONFIG
|
@@ -83,12 +97,12 @@ class TestAppGenerator < Rails::Generators::Base
|
|
83
97
|
insert_into_file "app/models/solr_document.rb", after: "include BlacklightOaiProvider::SolrDocument\n" do
|
84
98
|
<<-CONFIG
|
85
99
|
field_semantics.merge!(
|
86
|
-
title: "
|
87
|
-
|
88
|
-
|
89
|
-
|
100
|
+
title: "title_tsim",
|
101
|
+
date: "pub_date_ssim",
|
102
|
+
subject: "subject_ssim",
|
103
|
+
creator: "author_tsim",
|
90
104
|
format: "format",
|
91
|
-
language: "
|
105
|
+
language: "language_ssim",
|
92
106
|
)
|
93
107
|
CONFIG
|
94
108
|
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CatalogController < ApplicationController
|
4
|
+
include Blacklight::Catalog
|
5
|
+
include BlacklightOaiProvider::Controller
|
6
|
+
|
7
|
+
configure_blacklight do |config|
|
8
|
+
## Class for sending and receiving requests from a search index
|
9
|
+
# config.repository_class = Blacklight::Solr::Repository
|
10
|
+
#
|
11
|
+
## Class for converting Blacklight's url parameters to into request parameters for the search index
|
12
|
+
# config.search_builder_class = ::SearchBuilder
|
13
|
+
#
|
14
|
+
## Model that maps search index responses to the blacklight response model
|
15
|
+
# config.response_model = Blacklight::Solr::Response
|
16
|
+
|
17
|
+
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
18
|
+
config.default_solr_params = {
|
19
|
+
rows: 10
|
20
|
+
}
|
21
|
+
|
22
|
+
# solr path which will be added to solr base url before the other solr params.
|
23
|
+
# config.solr_path = 'select'
|
24
|
+
|
25
|
+
# items to show per page, each number in the array represent another option to choose from.
|
26
|
+
# config.per_page = [10,20,50,100]
|
27
|
+
|
28
|
+
## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
|
29
|
+
## parameters included in the Blacklight-jetty document requestHandler.
|
30
|
+
#
|
31
|
+
# config.default_document_solr_params = {
|
32
|
+
# qt: 'document',
|
33
|
+
# ## These are hard-coded in the blacklight 'document' requestHandler
|
34
|
+
# # fl: '*',
|
35
|
+
# # rows: 1,
|
36
|
+
# # q: '{!term f=id v=$id}'
|
37
|
+
# }
|
38
|
+
|
39
|
+
# solr field configuration for search results/index views
|
40
|
+
config.index.title_field = 'title_tsim'
|
41
|
+
config.index.display_type_field = 'format'
|
42
|
+
# config.index.thumbnail_field = 'thumbnail_path_ss'
|
43
|
+
|
44
|
+
# solr field configuration for document/show views
|
45
|
+
# config.show.title_field = 'title_ssim'
|
46
|
+
# config.show.display_type_field = 'format'
|
47
|
+
# config.show.thumbnail_field = 'thumbnail_path_ss'
|
48
|
+
|
49
|
+
# solr fields that will be treated as facets by the blacklight application
|
50
|
+
# The ordering of the field names is the order of the display
|
51
|
+
#
|
52
|
+
# Setting a limit will trigger Blacklight's 'more' facet values link.
|
53
|
+
# * If left unset, then all facet values returned by solr will be displayed.
|
54
|
+
# * If set to an integer, then "f.somefield.facet.limit" will be added to
|
55
|
+
# solr request, with actual solr request being +1 your configured limit --
|
56
|
+
# you configure the number of items you actually want _ssimed_ in a page.
|
57
|
+
# * If set to 'true', then no additional parameters will be sent to solr,
|
58
|
+
# but any 'sniffed' request limit parameters will be used for paging, with
|
59
|
+
# paging at requested limit -1. Can sniff from facet.limit or
|
60
|
+
# f.specific_field.facet.limit solr request params. This 'true' config
|
61
|
+
# can be used if you set limits in :default_solr_params, or as defaults
|
62
|
+
# on the solr side in the request handler itself. Request handler defaults
|
63
|
+
# sniffing requires solr requests to be made with "echoParams=all", for
|
64
|
+
# app code to actually have it echo'd back to see it.
|
65
|
+
#
|
66
|
+
# :show may be set to false if you don't want the facet to be drawn in the
|
67
|
+
# facet bar
|
68
|
+
#
|
69
|
+
# set :index_range to true if you want the facet pagination view to have facet prefix-based navigation
|
70
|
+
# (useful when user clicks "more" on a large facet and wants to navigate alphabetically across a large set of results)
|
71
|
+
# :index_range can be an array or range of prefixes that will be used to create the navigation (note: It is case sensitive when searching values)
|
72
|
+
|
73
|
+
config.add_facet_field 'format', label: 'Format'
|
74
|
+
config.add_facet_field 'pub_date_ssim', label: 'Publication Year', single: true
|
75
|
+
config.add_facet_field 'subject_tsim', label: 'Topic', limit: 20, index_range: 'A'..'Z'
|
76
|
+
config.add_facet_field 'language_ssim', label: 'Language', limit: true
|
77
|
+
config.add_facet_field 'lc_1letter_ssim', label: 'Call Number'
|
78
|
+
config.add_facet_field 'subject_geo_ssim', label: 'Region'
|
79
|
+
config.add_facet_field 'subject_era_ssim', label: 'Era'
|
80
|
+
|
81
|
+
config.add_facet_field 'example_pivot_field', label: 'Pivot Field', pivot: %w[format language_ssim]
|
82
|
+
|
83
|
+
config.add_facet_field 'example_query_facet_field', label: 'Publish Date', query: {
|
84
|
+
years_5: { label: 'within 5 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 5} TO *]" },
|
85
|
+
years_10: { label: 'within 10 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 10} TO *]" },
|
86
|
+
years_25: { label: 'within 25 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 25} TO *]" }
|
87
|
+
}
|
88
|
+
|
89
|
+
# Have BL send all facet field names to Solr, which has been the default
|
90
|
+
# previously. Simply remove these lines if you'd rather use Solr request
|
91
|
+
# handler defaults, or have no facets.
|
92
|
+
config.add_facet_fields_to_solr_request!
|
93
|
+
|
94
|
+
# solr fields to be displayed in the index (search results) view
|
95
|
+
# The ordering of the field names is the order of the display
|
96
|
+
config.add_index_field 'title_tsim', label: 'Title'
|
97
|
+
config.add_index_field 'title_vern_tsim', label: 'Title'
|
98
|
+
config.add_index_field 'author_tsim', label: 'Author'
|
99
|
+
config.add_index_field 'author_vern_tsim', label: 'Author'
|
100
|
+
config.add_index_field 'format', label: 'Format'
|
101
|
+
config.add_index_field 'language_ssim', label: 'Language'
|
102
|
+
config.add_index_field 'published_ssim', label: 'Published'
|
103
|
+
config.add_index_field 'published_vern_ssim', label: 'Published'
|
104
|
+
config.add_index_field 'lc_callnum_ssim', label: 'Call number'
|
105
|
+
|
106
|
+
# solr fields to be displayed in the show (single result) view
|
107
|
+
# The ordering of the field names is the order of the display
|
108
|
+
config.add_show_field 'title_ssim', label: 'Title'
|
109
|
+
config.add_show_field 'title_vern_ssim', label: 'Title'
|
110
|
+
config.add_show_field 'subtitle_tsim', label: 'Subtitle'
|
111
|
+
config.add_show_field 'subtitle_vern_tsim', label: 'Subtitle'
|
112
|
+
config.add_show_field 'author_tsim', label: 'Author'
|
113
|
+
config.add_show_field 'author_vern_tsim', label: 'Author'
|
114
|
+
config.add_show_field 'format', label: 'Format'
|
115
|
+
config.add_show_field 'url_fulltext_ssim', label: 'URL'
|
116
|
+
config.add_show_field 'url_suppl_ssim', label: 'More Information'
|
117
|
+
config.add_show_field 'language_ssim', label: 'Language'
|
118
|
+
config.add_show_field 'published_ssim', label: 'Published'
|
119
|
+
config.add_show_field 'published_vern_ssim', label: 'Published'
|
120
|
+
config.add_show_field 'lc_callnum_ssim', label: 'Call number'
|
121
|
+
config.add_show_field 'isbn_ssim', label: 'ISBN'
|
122
|
+
|
123
|
+
# "fielded" search configuration. Used by pulldown among other places.
|
124
|
+
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
125
|
+
#
|
126
|
+
# Search fields will inherit the :qt solr request handler from
|
127
|
+
# config[:default_solr_parameters], OR can specify a different one
|
128
|
+
# with a :qt key/value. Below examples inherit, except for subject
|
129
|
+
# that specifies the same :qt as default for our own internal
|
130
|
+
# testing purposes.
|
131
|
+
#
|
132
|
+
# The :key is what will be used to identify this BL search field internally,
|
133
|
+
# as well as in URLs -- so changing it after deployment may break bookmarked
|
134
|
+
# urls. A display label will be automatically calculated from the :key,
|
135
|
+
# or can be specified manually to be different.
|
136
|
+
|
137
|
+
# This one uses all the defaults set by the solr request handler. Which
|
138
|
+
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
139
|
+
# since we aren't specifying it otherwise.
|
140
|
+
|
141
|
+
config.add_search_field 'all_fields', label: 'All Fields'
|
142
|
+
|
143
|
+
# Now we see how to over-ride Solr request handler defaults, in this
|
144
|
+
# case for a BL "search field", which is really a dismax aggregate
|
145
|
+
# of Solr search fields.
|
146
|
+
|
147
|
+
config.add_search_field('title') do |field|
|
148
|
+
# solr_parameters hash are sent to Solr as ordinary url query params.
|
149
|
+
field.solr_parameters = {
|
150
|
+
'spellcheck.dictionary': 'title',
|
151
|
+
qf: '${title_qf}',
|
152
|
+
pf: '${title_pf}'
|
153
|
+
}
|
154
|
+
end
|
155
|
+
|
156
|
+
config.add_search_field('author') do |field|
|
157
|
+
field.solr_parameters = {
|
158
|
+
'spellcheck.dictionary': 'author',
|
159
|
+
qf: '${author_qf}',
|
160
|
+
pf: '${author_pf}'
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
# Specifying a :qt only to show it's possible, and so our internal automated
|
165
|
+
# tests can test it. In this case it's the same as
|
166
|
+
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
|
167
|
+
config.add_search_field('subject') do |field|
|
168
|
+
field.qt = 'search'
|
169
|
+
field.solr_parameters = {
|
170
|
+
'spellcheck.dictionary': 'subject',
|
171
|
+
qf: '${subject_qf}',
|
172
|
+
pf: '${subject_pf}'
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
176
|
+
# "sort results by" select (pulldown)
|
177
|
+
# label in pulldown is followed by the name of the SOLR field to sort by and
|
178
|
+
# whether the sort is ascending or descending (it must be asc or desc
|
179
|
+
# except in the relevancy case).
|
180
|
+
config.add_sort_field 'score desc, pub_date_ssim desc, title_si asc', label: 'relevance'
|
181
|
+
config.add_sort_field 'pub_date_ssim desc, title_si asc', label: 'year'
|
182
|
+
config.add_sort_field 'author_si asc, title_si asc', label: 'author'
|
183
|
+
config.add_sort_field 'title_si asc, pub_date_ssim desc', label: 'title'
|
184
|
+
|
185
|
+
# If there are more than this many search results, no spelling ("did you
|
186
|
+
# mean") suggestion is offered.
|
187
|
+
config.spell_max = 5
|
188
|
+
|
189
|
+
# Configuration for autocomplete suggestor
|
190
|
+
config.autocomplete_enabled = true
|
191
|
+
config.autocomplete_path = 'suggest'
|
192
|
+
# if the name of the solr.SuggestComponent provided in your solrcongig.xml is not the
|
193
|
+
# default 'mySuggester', uncomment and provide it below
|
194
|
+
# config.autocomplete_suggester = 'mySuggester'
|
195
|
+
end
|
196
|
+
end
|