blacklight 5.9.4 → 5.10.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,90 +0,0 @@
1
- Blacklight will provide atom responses for all catalog/index results. Just add ".atom" on to the end of your path component, `/catalog.atom`, or `/catalog/index.atom`.
2
- ```xml
3
- <?xml version="1.0" encoding="UTF-8"?>
4
- <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
5
- <title>Blacklight Search Results</title>
6
- <author>
7
- <name>Blacklight</name>
8
- </author>
9
- <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="self"/>
10
- <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="alternate" type="text/html"/>
11
- <id>http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields&amp;amp;type=text%2Fhtml</id>
12
- <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=2&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="next"/>
13
- <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=1&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="first"/>
14
- <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=15&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="last"/>
15
- <link href="http://demo.projectblacklight.org/catalog/opensearch.xml" rel="search" type="application/opensearchdescription+xml"/>
16
- <opensearch:totalResults>147</opensearch:totalResults>
17
- <opensearch:startIndex>0</opensearch:startIndex>
18
- <opensearch:itemsPerPage>10</opensearch:itemsPerPage>
19
- <opensearch:Query searchTerms="urdu" startPage="1" role="request"/>
20
- <updated>2011-05-11T17:46:58Z</updated>
21
- <entry>
22
- <title>Urdu&#772; d&#803;ra&#772;ma&#772;</title>
23
- <updated>2011-05-11T17:46:58Z</updated>
24
- <link href="http://demo.projectblacklight.org/catalog/2008306442" rel="alternate" type="text/html"/>
25
- <link href="http://demo.projectblacklight.org/catalog/2008306442.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
26
- <link href="http://demo.projectblacklight.org/catalog/2008306442.xml" rel="alternate" title="xml" type="application/xml" />
27
- <id>http://demo.projectblacklight.org/catalog/2008306442</id>
28
- <author>
29
- <name>Farg&#818;h&#818;a&#772;nah, 1979-</name>
30
- </author>
31
- <summary type="html">
32
- &lt;dl class="defList"&gt;
33
-
34
-
35
- &lt;dt class="blacklight-title_display"&gt;Title:&lt;/dt&gt;
36
- &lt;dd class="blacklight-title_display"&gt;Urdu&#772; d&#803;ra&#772;ma&#772;&lt;/dd&gt;
37
-
38
- &lt;dt class="blacklight-author_display"&gt;Author:&lt;/dt&gt;
39
- &lt;dd class="blacklight-author_display"&gt;Farg&#818;h&#818;a&#772;nah, 1979-&lt;/dd&gt;
40
-
41
-
42
- <!-- [...] -->
43
- &lt;/dl&gt;
44
- </summary>
45
- </entry>
46
- <!-- [...] -->
47
- </feed>
48
- ```
49
-
50
-
51
- The same HTML summary included in your HTML results pages are included as an `atom:summary` element -- the atom template uses the `[[#render_document_partial|https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight/blacklight_helper_behavior.rb#L203]]` helper method to generate this HTML summary, so if you've over-ridden that for your app, it will be used as the `atom:summary` content instead.
52
-
53
- ## API Usage
54
- The Atom response is intended to be pretty full of data, so it can fill many traditional API requests. It makes use of every relevant atom or [[OpenSearch|http://www.opensearch.org/Home]] element that could be conveniently included.
55
-
56
- The Atom response also supports arbitrary format representations in the `atom:content` element. You can include `&content_format=some_format` in your request URL (e.g. `[[/catalog.atom?content_format=oai_dc_xml|http://demo.projectblacklight.org/catalog.atom?q=urdu&content_format=oai_dc_xml]]`). Any format a given document can be exported as using the [[Blacklight document framework|Extending-blacklight-with-the-document-extension-framework]] is available. Not every document can export in every format -- if a format is requested one or more of the items in your atom result can not export as, it will not have an `atom:content` element. Non-XML-based formats are supported, as the content is Base64-encoded (as per Atom spec, unless the format is `text/plain`).
57
- ```xml
58
- <?xml version="1.0" encoding="UTF-8"?>
59
- <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
60
- <title>Blacklight Search Results</title>
61
- <author>
62
- <name>Blacklight</name>
63
- </author>
64
- <link href="http://demo.projectblacklight.org/?content_format=oai_dc_xml&amp;amp;format=atom&amp;amp;per_page=1" rel="self"/>
65
- <!-- [...] -->
66
- <entry>
67
- <title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</title>
68
- <updated>2011-05-11T17:59:32Z</updated>
69
- <link href="http://demo.projectblacklight.org/catalog/u1" rel="alternate" type="text/html"/>
70
- <link href="http://demo.projectblacklight.org/catalog/u1.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
71
- <link href="http://demo.projectblacklight.org/catalog/u1.xml" rel="alternate" title="xml" type="application/xml" />
72
- <id>http://demo.projectblacklight.org/catalog/u1</id>
73
- <author>
74
- <name>Roatcap, Adela Spindler</name>
75
- </author>
76
- <summary type="html">
77
- <!-- [...] -->
78
- </summary>
79
- <!-- [ Here is the export format as OAI Dublin Core XML ] -->
80
- <content type="text/xml">
81
- <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:language>English</dc:language><dc:title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</dc:title><dc:format>Book</dc:format></oai_dc:dc> </content>
82
- </entry>
83
- </feed>
84
- ```
85
-
86
- This means that if you add on a document extension that provides more export formats for some or all of your documents, that will automatically be available in the atom response.
87
-
88
- If you choose to use the [[Blacklight CQL add-on|https://github.com/projectblacklight/blacklight_cql]], the combination of [[CQL|http://www.loc.gov/standards/sru/specs/cql.html]] requests and Atom responses provides a pretty good more-or-less standards-based API to search results through Blacklight.
89
-
90
- The Atom response generating template is at `app/views/catalog/index.builder.atom`.
@@ -1,23 +0,0 @@
1
- ## Stable Add-ons
2
-
3
- A few add-ons are are more or less 'officially supported', and all Blacklight developers have commit rights on them. (although some may not have received attention in a while if developers have been busy. Feel free to ask on the list for current status):
4
-
5
- * [Advanced search](https://github.com/projectblacklight/blacklight_advanced_search)
6
- * [CQL search](https://github.com/projectblacklight/blacklight_cql)
7
- * [Date range limit](https://github.com/projectblacklight/blacklight_range_limit).
8
-
9
- ## In development
10
- * [Blacklight Gallery](https://github.com/projectblacklight/blacklight-gallery)
11
- * [Blacklight Maps](https://github.com/sul-dlss/blacklight-maps)
12
- * [Spotlight](https://github.com/sul-dlss/spotlight) Curated digital collections
13
- * [blacklight-oembed](https://github.com/sul-dlss/blacklight-oembed) Embedding oEmbed resources in search results
14
- * [GeoBlacklight](https://github.com/geoblacklight/geoblacklight) Discovery and access for geospatial data
15
-
16
- ## Unstable/Experimental
17
-
18
- * [[Blacklight Sitemap Generator|https://github.com/jronallo/blacklight-sitemap]]: Rake task for generating sitemaps.
19
- * [[Blacklight OAI provider|https://github.com/cbeer/blacklight_oai_provider]]: Adds an [[OAI-PMH|http://www.openarchives.org/pmh/]] provider using the [[oai|http://rubygems.org/gems/oai]] gem for harvesting records within Blacklight.
20
- * [[Blacklight unAPI|https://github.com/cbeer/blacklight_unapi]]: Adds an [[unAPI|http://unapi.info]] endpoint for records within Blacklight.
21
- * [[Blacklight User Generated Content|https://github.com/cbeer/blacklight_user_generated_content]]: Adds user generated content to SolrDocument objects using acts_as_commentable, acts_as_taggable and acts_as_rateable directly against a SolrDocument object.
22
- * [[Blacklight oEmbed|https://github.com/cbeer/blacklight_oembed]]: [[oEmbed|http://oembed.com]] endpoint that provides framework for allowing third-party sites (Wordpress, Facebook, etc) to embed content given a URL.
23
- * [[Blacklight Google Analytics|https://github.com/jronallo/blacklight_google_analytics]]: Quick start for setting up Google Analytics for a Blacklight site, including Event Tracking of Blacklight-specific page elements like facets.
@@ -1,411 +0,0 @@
1
- # Configuring Blacklight to work with your Solr index
2
-
3
- In order to fully understand this section, you should be familiar with Solr, ways to index data into Solr, how to configure request handlers, and how to change a Solr schema. Those topics are covered in the official [Apache Solr Tutorial](http://lucene.apache.org/solr/tutorial.html).
4
-
5
- The Blacklight example configuration is a (simplified) way to work with library data (in the MARC format), it is (hopefully) easy to reconfigure to work with your Solr index. In this section, we will describe most of the Blacklight configuration settings that determine how the Blacklight interface works with your data. Later sections demonstrate how to modify the Blacklight user experience and templates, etc.
6
-
7
- > Note: In most of this section, we will show how to configure Blacklight to request data from Solr. While this works, and makes it easy to rapidly develop an application, we recommend eventually configuring your Apache Solr request handlers to do this instead.
8
-
9
-
10
- ## Connecting to Solr: config/solr.yml
11
-
12
- Your Blacklight-based application will interact with your Solr index. Although Blacklight does distribute a sample jetty-based Solr instance, you will likely want to connect Blacklight to your own Solr index. The Solr index to use is specified in a configuration file, ```config/solr.yml```. If you open this file in a recently generated Blacklight application, you’ll see a default solr configured to use a single-core Solr running under jetty:
13
-
14
- ```yaml
15
- development:
16
- url: http://127.0.0.1:8983/solr
17
-
18
- test:
19
- url: http://127.0.0.1:8888/solr
20
- ```
21
-
22
- When you run your Rails application in the ```development``` environment, it will try to connect to Solr at ```http://127.0.0.1:8983/solr```, and, likewise, in ```test```, it will try to connect to Solr at ```http://127.0.0.1:8888/solr```.
23
-
24
- This URL should point to the base path of your Solr application, and includes e.g. Solr core names (see below), but not request handler paths, etc.
25
-
26
- Blacklight uses the RSolr gem to talk to Solr. The parameters are passed to [RSolr.connect](http://rubydoc.info/gems/rsolr/1.0.6/RSolr.connect).
27
-
28
- ### Using Blacklight with a Multicore Solr
29
-
30
- Here's an example of using a Multi-core Solr install with Blacklight:
31
-
32
- ```yaml
33
- development:
34
- url: http://127.0.0.1:8983/solr/development-core
35
- test:
36
- url: http://127.0.0.1:8983/solr/test-core
37
- ```
38
-
39
- ### Running and Monitoring Solr with Foreman
40
-
41
- You can use [foreman](http://blog.daviddollar.org/2011/05/06/introducing-foreman.html) to start up and monitor the blacklight rails app and the solr server. Here is an example Procfile:
42
-
43
- web: bundle exec rails s -p $PORT
44
- solr: bash -c "cd ./jetty; java -jar -Djetty.port=$PORT start.jar"
45
-
46
- ## Blacklight Configuration
47
-
48
- Now that you've connected to Solr, you probably want to configure Blacklight to display your Solr fields in the search results and facets, and also use your fields for search fields, sort options. This configuration goes in your CatalogController. By convention, this is in your Rails application, and is located at [```app/controllers/catalog_controller.rb```](https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/catalog_controller.rb).
49
-
50
- The CatalogController includes functionality and templates for searching and displaying documents. The CatalogController needs to be configured so it knows about your Solr fields.
51
-
52
- > NOTE: While most applications use only a single controller for search, it is possible to have multiple controllers with different configurations. This documentation will only discuss the simple case.
53
-
54
- ### default_solr_params
55
-
56
- The default_solr_params are parameters that will be sent to the Solr API on all search-like requests:
57
-
58
- ```ruby
59
- config.default_solr_params = {
60
- :qt => 'search',
61
- :rows => 10
62
- }
63
- ```
64
-
65
- This configuration would send the following for any request to solr:
66
-
67
- ```
68
- http://localhost:8983/solr/select?qt=search&rows=10
69
- ```
70
-
71
- While the default_solr_params are useful for rapid development, they are often moved into the Solr request handler for production deployments.
72
-
73
- A counter-part to default_solr_params is default_document_solr_params, which is sent when requesting only a single document from solr. In the Blacklight example solrconfig.xml, there is a `document` requestHandler to retrieve a single document at a time. We encourage you to adopt pattern as well, but with an existing Solr installation adding a single document requestHandler may not be an option. Instead, you can modify the `default_document_solr_params` to configure the appropriate defaults:
74
-
75
- ```ruby
76
- # See SolrHelper#solr_doc_params
77
- config.default_document_solr_params = {
78
- :qt => 'document',
79
- ## These are hard-coded in the blacklight 'document' requestHandler
80
- # :fl => '*',
81
- # :rows => 1
82
- # :q => '{!raw f=id v=$id}'
83
- }
84
- ```
85
-
86
- Blacklight will add a query parameter called `id` containing the unique key for your document. It can be referenced as a Solr local parameter (as above) in your queries.
87
-
88
-
89
- ### Results views (index and show)
90
-
91
-
92
- You can configure the fields and labels that are display for search results on the search and document views.
93
-
94
- > Note: these must be STORED fields in the Solr index, and must be returned in the solr response or they will not be displayed.
95
-
96
- There's a set of configuration parameters for the title and Blacklight template handling (discussed elsewhere):
97
-
98
- ```ruby
99
- # solr field configuration for search results/index views
100
- config.index.show_link = 'title_display'
101
- config.index.record_display_type = 'format'
102
-
103
- # solr field configuration for document/show views
104
- config.show.html_title = 'title_display'
105
- config.show.heading = 'title_display'
106
- config.show.display_type = 'format'
107
- ```
108
-
109
- This configuration will use the ```title_display``` Solr field as the link text for each document.
110
-
111
- There's a separate section for the additional fields to display:
112
-
113
- ```ruby
114
- # [from app/controllers/catalog_controller.rb]
115
- # solr fields to be displayed in the index (search results) view
116
- # The ordering of the field names is the order of the display
117
- config.add_index_field 'title_display', :label => 'Title:'
118
- config.add_index_field 'title_vern_display', :label => 'Title:'
119
- config.add_index_field 'author_display', :label => 'Author:'
120
- config.add_index_field 'author_vern_display', :label => 'Author:'
121
-
122
- # ...
123
- # And likewise for the show (single-document) view:
124
-
125
- config.add_show_field 'title_display', :label => 'Title:'
126
- config.add_show_field 'title_vern_display', :label => 'Title:'
127
- config.add_show_field 'subtitle_display', :label => 'Subtitle:'
128
- ```
129
-
130
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/index_fields.png|frame|alt=Index Fields]]
131
-
132
- #### Linking a value to a facet search
133
-
134
- When rendering the format value in the search results, link the value to a facet search for that value:
135
-
136
- ```ruby
137
- config.add_index_field 'format', :label => 'Format:', :link_to_search => true
138
- ```
139
-
140
- Or specify the field to facet against, explicitly:
141
- ```ruby
142
- config.add_index_field 'author_display', :label => 'Author:', :link_to_search => :author_facet
143
- ```
144
-
145
- More advanced configuration should use a custom helper method (see below) to render an appropriate value.
146
-
147
- #### Using a helper method to render the value
148
-
149
- You can use view helpers to render the Solr values, e.g.:
150
-
151
- ```ruby
152
- config.add_index_field 'title_vern_display', :label => 'Title:', :helper_method => :my_helper_method
153
- ```
154
-
155
- When Blacklight goes to display the 'title_vern_display' field, it will call ```my_helper_method``` to get the value to display. You can implement any logic you want to manipulate the solr document to return the value to display.
156
-
157
- ```ruby
158
- module ApplicationHelper
159
- def my_helper_method args
160
- args[:document][args[:field]].upcase
161
- end
162
- end
163
- ```
164
-
165
- Your helper method receives hash with (at least) two parameters:
166
-
167
- - :document => the SolrDocument object
168
- - :field => the solr field to display
169
-
170
-
171
- #### Solr hit highlighting
172
-
173
- You can trigger automatic Solr hit highlighting of results:
174
-
175
- ```ruby
176
- config.add_index_field 'title_vern_display', :label => 'Title:', :highlight => true
177
- ```
178
-
179
- This will cause Blacklight to look at the Solr highlight component response for the value of this field. This assumes you've configured the highlighting component elsewhere. The [Solr Highlighting Parameters](http://wiki.apache.org/solr/HighlightingParameters) documentation discusses the Solr parameters available to you. You could add these to your default_solr_params, request handler configuration, or elsewhere.
180
-
181
- You can have Blacklight send the most basic highlighting parameters for you, if you set:
182
-
183
- ```ruby
184
- config.add_field_configuration_to_solr_request!
185
- ```
186
-
187
- This will enable the highlighting component and send 'hl.fl' parameters for the fields you wanted highlighted, but you will likely want to tweak this behavior further.
188
-
189
- ### Facet fields
190
-
191
- Faceted search allows users to constrain searches by controlled vocabulary items
192
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_facets.png|frame|alt=Search facets in action]]
193
- Note that these must be INDEXED fields in the Solr index, and are generally a single token (e.g. a string).
194
-
195
- ```ruby
196
- # [from app/controllers/catalog_controller.rb]
197
- # solr fields that will be treated as facets by the blacklight application
198
- # The ordering of the field names is the order of the display
199
- config.add_facet_field 'format', :label => 'Format'
200
- config.add_facet_field 'pub_date', :label => 'Publication Year'
201
- config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
202
- config.add_facet_field 'language_facet', :label => 'Language', :limit => true
203
- ```
204
-
205
- ### Facet View Helpers [v.4.2.0+]
206
-
207
- You can supply a :helper_method argument to configure what you would like displayed for the facet's text, e.g:
208
-
209
- ```ruby
210
- config.add_facet_field 'format', :label => 'Format', :helper_method => :my_helper_method
211
- ```
212
-
213
- With the above code Blacklight will pass the facet's value into the given helper method, with which you can do anything you'd like.
214
-
215
- ```ruby
216
- module ApplicationHelper
217
- def my_helper_method value
218
- value.upcase
219
- end
220
- end
221
- ```
222
- ### Facet Queries
223
- Blacklight also supports Solr facet queries:
224
-
225
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/query_facets.png|frame|alt=Query facets in action]]
226
-
227
- ```ruby
228
- config.add_facet_field 'pub_date_query', :label => 'Publication Year', :query => {
229
- :last_5_years => { :label => 'Last 5 Years', :fq => "[#{Time.now.year-5} TO *]"}
230
- }
231
- ```
232
-
233
- The first argument (which maps to the facet field for plain facets) is used in the Blacklight URL when the facet is selected.
234
-
235
- The :query hash maps a key to use in Blacklight URLs to a facet :label (used in the facet display) and an :fq to send to Solr as the `facet.query` and (if selected) the Solr `fq` parameter.
236
-
237
- You can also tell Solr how to sort facets (either by [count or index](http://wiki.apache.org/solr/SimpleFacetParameters#facet.sort)):
238
- If your data is strings, you can use this to perform an alphabetical sort of the facets.
239
- ```ruby
240
- config.add_facet_field :my_count_sorted_field, :sort => 'count'
241
- config.add_facet_field :my_index_sorted_field, :sort => 'index'
242
- ```
243
-
244
-
245
- If you want Solr to add the configured facets and facet queries to the Solr query it sends, you should also add:
246
-
247
- ```ruby
248
- config.add_facet_fields_to_solr_request! # deprecated: use add_facet_field :include_in_request instead
249
- ```
250
-
251
- ### Date-based facets
252
-
253
- If you have date facets in Solr, you should add a hint to the Blacklight configuration:
254
-
255
- ```ruby
256
- config.add_facet_field :my_date_field, :date => true
257
- ```
258
-
259
- This will trigger special date querying logic, and also use a localized date format when displaying the facet value. If you want to use a particular localization format, you can provide that as well:
260
-
261
- ```ruby
262
- config.add_facet_field :my_date_field, :date => { :format => :short }
263
- ```
264
-
265
- ### Tagging/Exclusion facets
266
-
267
- From the solr docs:
268
-
269
- > One can tag specific filters and exclude those filters when faceting. This is generally needed when doing multi-select faceting. [...]To implement a multi-select facet for doctype, a GUI may want to still display the other doctype values and their associated counts, as if the doctype:pdf constraint had not yet been applied.
270
- >
271
- > Example:
272
- >
273
- > === Document Type ===
274
- >
275
- > [ ] Word (42)
276
- >
277
- > [x] PDF (96)
278
- >
279
- > [ ] Excel(11)
280
- >
281
- > [ ] HTML (63)
282
-
283
- To configure this behavior in Blacklight,
284
-
285
- ```ruby
286
- config.add_facet_field :document_type_facet, :tag => 'some-tag', :ex => 'some-tag'
287
- ```
288
-
289
- ### search fields
290
-
291
- Search queries can be targeted at configurable fields (or sets of fields) to return precise search results. Advanced search capabilities are provided through the [[Advanced Search Add-On|https://github.com/projectblacklight/blacklight_advanced_search]]
292
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png|frame|alt=Search fields in action]]
293
-
294
- ```ruby
295
- # [from app/controllers/catalog_controller.rb]
296
- # Now we see how to over-ride Solr request handler defaults, in this
297
- # case for a BL "search field", which is really a dismax aggregate
298
- # of Solr search fields.
299
-
300
- config.add_search_field('title') do |field|
301
- # solr_parameters hash are sent to Solr as ordinary url query params.
302
- field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
303
-
304
- # :solr_local_parameters will be sent using Solr LocalParams
305
- # syntax, as eg {! qf=$title_qf }. This is neccesary to use
306
- # Solr parameter de-referencing like $title_qf.
307
- # See: http://wiki.apache.org/solr/LocalParams
308
- field.solr_local_parameters = {
309
- :qf => '$title_qf',
310
- :pf => '$title_pf'
311
- }
312
- end
313
- ```
314
-
315
- ### sort fields
316
-
317
- ```ruby
318
- config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
319
- config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
320
- config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
321
- config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
322
- ```
323
-
324
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/sort_fields.png|frame|alt=Sort fields in action]]
325
-
326
- > TODO
327
-
328
- ## Solr Document
329
-
330
-
331
- By default, Blacklight assumes the unique key field in your solr index is called `id`. You can change this by editing `app/models/solr_document.rb`:
332
-
333
- ```ruby
334
- class SolrDocument
335
- include Blacklight::Solr::Document
336
-
337
- # self.unique_key = 'id'
338
- ...
339
- end
340
- ```
341
-
342
- If, for instance, your unique key field was 'uuid_s', this would read:
343
-
344
- ```ruby
345
- class SolrDocument
346
- include Blacklight::Solr::Document
347
-
348
- self.unique_key = 'uuid_s'
349
- ...
350
- end
351
- ```
352
-
353
- This will instruct Blacklight to use your ```uuid_s``` field any time it needs an identifier for the document, e.g. when constructing document URLs.
354
-
355
- Also in SolrDocument is a set of "field semantics", which may be used in some basic metadata mapping:
356
-
357
- ```ruby
358
- class SolrDocument
359
- ...
360
-
361
- field_semantics.merge!(
362
- :title => "title_display",
363
- :author => "author_display",
364
- :language => "language_facet",
365
- :format => "format"
366
- )
367
- end
368
- ```
369
-
370
- ### Field Collapsing
371
-
372
- Blacklight 4.4 adds support for Solr Field Collapsing (aka results grouping). The initial implementation requires you to explicitly configure your solr request handler (or default solr parameters) to enable grouping.
373
-
374
- Here are some solr request parameters to enable grouping on our demo index:
375
-
376
- ```
377
- :group => true,
378
- :'group.field' => 'pub_date_sort',
379
- :'group.ngroups' => true, # group.ngroups is REQUIRED.
380
- :'group.limit' => 3
381
- ```
382
-
383
- If you only define a single group.field, Blacklight will detect the grouped response and use it. If there are multiple fields defined, you have to configure Blacklight to detect the correct field, e.g.:
384
-
385
- ```
386
- config.index.group = "pub_date_sort"
387
- ```
388
-
389
- ### Thumbnails in results display
390
-
391
- Blacklight 4.4+ can render a representative thumbnail with a result on the search index page.
392
-
393
- Blacklight can pull a URL to the thumbnail from a field in Solr:
394
-
395
- ```ruby
396
- configure_blacklight do |config|
397
- config.index.thumbnail_field = :some_field_in_the_document
398
- end
399
- ```
400
-
401
- Or using custom logic in a helper method of your own creation:
402
-
403
- ```ruby
404
- configure_blacklight do |config|
405
- config.index.thumbnail_method = :xyz
406
- end
407
- ```
408
-
409
- With this configuration, the helper method `xyz` will be called with the `SolrDocument` document and a hash of caller-supplied image options.
410
-
411
- Given that configuration, Blacklight will render a thumbnail (by default, right aligned, under the bookmark button) as a link to the document page. If no thumbnail is available (missing data in solr, the thumbnail method returned nil), the thumbnail block is not displayed at all.