blacklight 5.9.4 → 5.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +1 -4
- data/app/models/search.rb +3 -6
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +8 -48
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +0 -3
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/lib/blacklight.rb +70 -26
- data/lib/blacklight/abstract_repository.rb +29 -0
- data/lib/blacklight/base.rb +7 -7
- data/lib/blacklight/bookmarks.rb +5 -5
- data/lib/blacklight/catalog.rb +34 -19
- data/lib/blacklight/catalog/search_context.rb +1 -1
- data/lib/blacklight/configuration.rb +112 -46
- data/lib/blacklight/configuration/facet_field.rb +9 -7
- data/lib/blacklight/configuration/field.rb +27 -0
- data/lib/blacklight/configuration/fields.rb +25 -20
- data/lib/blacklight/configuration/search_field.rb +6 -8
- data/lib/blacklight/configuration/solr_field.rb +3 -18
- data/lib/blacklight/configuration/sort_field.rb +6 -7
- data/lib/blacklight/document.rb +156 -0
- data/lib/blacklight/document/dublin_core.rb +41 -0
- data/lib/blacklight/document/email.rb +16 -0
- data/lib/blacklight/document/export.rb +107 -0
- data/lib/blacklight/document/extensions.rb +56 -0
- data/lib/blacklight/document/schema_org.rb +7 -0
- data/lib/blacklight/document/semantic_fields.rb +51 -0
- data/lib/blacklight/document/sms.rb +14 -0
- data/lib/blacklight/document_presenter.rb +3 -3
- data/lib/blacklight/exceptions.rb +9 -2
- data/lib/blacklight/facet.rb +21 -16
- data/lib/blacklight/request_builders.rb +60 -284
- data/lib/blacklight/routes.rb +1 -1
- data/lib/blacklight/search_builder.rb +130 -0
- data/lib/blacklight/search_helper.rb +316 -0
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +4 -187
- data/lib/blacklight/solr/document/dublin_core.rb +3 -37
- data/lib/blacklight/solr/document/email.rb +4 -13
- data/lib/blacklight/solr/document/export.rb +3 -103
- data/lib/blacklight/solr/document/extensions.rb +4 -52
- data/lib/blacklight/solr/document/more_like_this.rb +1 -1
- data/lib/blacklight/solr/document/schema_org.rb +4 -4
- data/lib/blacklight/solr/document/sms.rb +4 -11
- data/lib/blacklight/solr/facet_paginator.rb +2 -2
- data/lib/blacklight/solr/search_builder.rb +264 -0
- data/lib/blacklight/solr_helper.rb +6 -261
- data/lib/blacklight/solr_repository.rb +30 -24
- data/lib/blacklight/solr_response.rb +3 -3
- data/lib/blacklight/user.rb +1 -2
- data/lib/blacklight/utils.rb +0 -23
- data/lib/generators/blacklight/controller_generator.rb +38 -0
- data/lib/generators/blacklight/document_generator.rb +20 -0
- data/lib/generators/blacklight/install_generator.rb +38 -39
- data/lib/generators/blacklight/models_generator.rb +2 -62
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
- data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
- data/lib/generators/blacklight/templates/solr_document.rb +6 -6
- data/lib/generators/blacklight/test_support_generator.rb +1 -6
- data/lib/generators/blacklight/user_generator.rb +59 -0
- data/lib/railties/blacklight.rake +16 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -15
- data/spec/features/facets_spec.rb +8 -0
- data/spec/helpers/configuration_helper_spec.rb +6 -13
- data/spec/helpers/facets_helper_spec.rb +3 -2
- data/spec/lib/blacklight/configuration_spec.rb +11 -38
- data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
- data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
- data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
- data/spec/lib/blacklight/search_builder_spec.rb +145 -0
- data/spec/lib/blacklight/search_helper_spec.rb +775 -0
- data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
- data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
- data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- data/template.demo.rb +1 -1
- metadata +33 -45
- data/doc/Adding-new-document-actions.md +0 -94
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-Add-ons.md +0 -23
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -100
- data/doc/Blacklight-out-of-the-box.md +0 -47
- data/doc/Bookmarks.md +0 -1
- data/doc/Code4Lib-2014.md +0 -94
- data/doc/Configuration---Facet-Fields.md +0 -130
- data/doc/Configuration---Results-View.md +0 -224
- data/doc/Configuration---Solr-fields.md +0 -106
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -43
- data/doc/Examples.md +0 -120
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -100
- data/doc/How-to-release-a-version.md +0 -45
- data/doc/Indexing-your-data-into-solr.md +0 -36
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -83
- data/doc/Pagination.md +0 -52
- data/doc/Providing-your-own-view-templates.md +0 -69
- data/doc/Quickstart.md +0 -153
- data/doc/README_SOLR.md +0 -245
- data/doc/Saved-Searches.md +0 -5
- data/doc/Solr-Configuration.md +0 -154
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Support.md +0 -33
- data/doc/Theming.md +0 -62
- data/doc/Understanding-Rails-and-Blacklight.md +0 -75
- data/doc/User-Authentication.md +0 -60
- data/doc/_Sidebar.md +0 -9
- data/doc/testing.md +0 -58
@@ -1,69 +0,0 @@
|
|
1
|
-
# Customizing the User Interface
|
2
|
-
## Layouts
|
3
|
-
|
4
|
-
Blacklight provides a layout called "blacklight" that provides the basic scaffolding to make Blacklight operate correctly. If you replace it with your own layout, you may wish to preserve some key features of the provided layout:
|
5
|
-
|
6
|
-
Call `content_for(:head)` somewhere in your HTML <head>:
|
7
|
-
```erb
|
8
|
-
<%= content_for(:head) %>
|
9
|
-
```
|
10
|
-
|
11
|
-
Render flash messages in the layout - none of the Blacklight-provided templates and partials are configured to do this for you.
|
12
|
-
|
13
|
-
Provide an AJAX modal:
|
14
|
-
|
15
|
-
```erb
|
16
|
-
<div id="ajax-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
|
17
|
-
<div class="modal-dialog">
|
18
|
-
<div class="modal-content">
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
```
|
23
|
-
|
24
|
-
|
25
|
-
## Overriding Views (templates and partials)
|
26
|
-
As a Rails Engine, you can easily override views in your app. You can see what views and partials are provided by looking in `[[./app/views|https://github.com/projectblacklight/blacklight/tree/master/app/views]]` inside the Blacklight source.
|
27
|
-
|
28
|
-
Once you find the view you'd like to change, you should create a file with the same name and relative path in your own application (e.g. if you wanted to override [[./app/views/catalog/_show_partials/_default.html.erb|https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_show_partials/_default.html.erb]] you would create ./app/views/catalog/_show_partials/_default.html.erb in your local application. Frequently, you will start by copying the existing Blacklight view and modifying it from there.
|
29
|
-
|
30
|
-
It is generally recommended that you override as little as possible, in order to maximize your forward compatibility. Look to override either a small, focused partial template, or a helper method of partial template called from a larger template, so your application's version can call out to those same helpers or partial templates within blacklight core code.
|
31
|
-
|
32
|
-
## Overriding the CatalogController
|
33
|
-
Overriding the Blacklight `CatalogController` implementation is easy, and the skeleton of the `CatalogController` is generated into your application for you when you install Blacklight.
|
34
|
-
|
35
|
-
See the [[Extending or Modifying Blacklight Search Behavior]] for tips and approaches to customizing the catalog.
|
36
|
-
|
37
|
-
## Custom View Helpers
|
38
|
-
|
39
|
-
(This is accurate for Blacklight 3.1.1 and subsequent. Before that, things were messier).
|
40
|
-
|
41
|
-
One of the most common things you might need to do is create a view helper -- especially to override some Blacklight behavior implemented in it's own view helpers. The first step is looking at Blacklight source to determine what view helper method you want to override.
|
42
|
-
|
43
|
-
Blacklight comes packaged with several view helper modules. There is a BlacklightHelper in (blacklight source) app/helpers/blacklight_helper.rb , and several others that correspond to specific controller. (Note, depending on version of Rails and configuration, all helpers may get loaded for every request, even ones that are named to correspond only to a particular other controller).
|
44
|
-
|
45
|
-
If you simply created a local helper with the same name as a helper in Blacklight, that will end up preventing the Blacklight helper from being loaded at all though, which is not what you want to do to override.
|
46
|
-
|
47
|
-
We've structured each Blacklight view helper module into two parts to make it easy to selectively over-ride methods. For instance, here's Blacklight's app/helpers/blacklight_helper.rb:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
module BlacklightHelper
|
51
|
-
include Blacklight::BlacklightHelperBehavior
|
52
|
-
end
|
53
|
-
```
|
54
|
-
|
55
|
-
Now, the actual methods will be found in app/helpers/blacklight/blacklight_helper_behavior.rb instead.
|
56
|
-
|
57
|
-
If you want to over-ride a helper method, copy the wrapper blacklight_helper into your local app, with the 'include' line, and now you can individually over-ride methods from BlacklightHelperBehavior, and the other methods you don't over-ride will still have their default implementation.
|
58
|
-
|
59
|
-
YOUR `app/helpers/blacklight_helper.rb`
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
module BlacklightHelper
|
63
|
-
include Blacklight::BlacklightHelperBehavior
|
64
|
-
|
65
|
-
def application_name
|
66
|
-
"Bestest University Search"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
```
|
data/doc/Quickstart.md
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
Blacklight is a Ruby on Rails Engine plugin, meaning it provides a small application that runs inside an existing Ruby on Rails project.
|
2
|
-
|
3
|
-
This Quickstart will walk you through installing Blacklight and Solr, and indexing a sample set of records. If you want information about configuring Blacklight to use an existing Solr index with your data in it, see the [Developing Your Application](https://github.com/projectblacklight/blacklight/wiki#wiki-blacklight-configuration) section of the wiki.
|
4
|
-
|
5
|
-
## Dependencies
|
6
|
-
To get started with Blacklight, first [install Ruby](https://gorails.com/setup/#ruby) and [install Rails](https://gorails.com/setup/#rails), if you don't have it installed already. You'll need Ruby 1.9 or higher, and Rails 3.2 or higher.
|
7
|
-
|
8
|
-
To run Solr, you'll also need Java installed.
|
9
|
-
|
10
|
-
### Got Ruby?
|
11
|
-
|
12
|
-
You should have Ruby 1.9 or greater installed.
|
13
|
-
|
14
|
-
```console
|
15
|
-
$ ruby --version
|
16
|
-
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
|
17
|
-
```
|
18
|
-
|
19
|
-
### Got Rails?
|
20
|
-
|
21
|
-
Blacklight works with Rails 3.2 and Rails 4.x, although we strongly encourage you to use Rails 4.
|
22
|
-
|
23
|
-
```console
|
24
|
-
$ rails --version
|
25
|
-
Rails 4.0.3
|
26
|
-
```
|
27
|
-
|
28
|
-
### Got Java?
|
29
|
-
|
30
|
-
```console
|
31
|
-
$ java -version
|
32
|
-
|
33
|
-
java version "1.6.0_0"
|
34
|
-
IcedTea6 1.3.1 (6b12-0ubuntu6.1) Runtime Environment (build 1.6.0_0-b12)
|
35
|
-
OpenJDK Client VM (build 1.6.0_0-b12, mixed mode, sharing)
|
36
|
-
```
|
37
|
-
|
38
|
-
The output will vary, but you need to make sure you have version 1.6 or higher. If you don't have the required version, or if the java command is not found, download and install the latest version from Oracle at http://www.oracle.com/technetwork/java/javase/downloads/index.html. Make sure to install the JDK.
|
39
|
-
|
40
|
-
## Creating a new application the easy way
|
41
|
-
|
42
|
-
```console
|
43
|
-
$ mkdir projects
|
44
|
-
$ cd projects
|
45
|
-
$ rails new search_app -m https://raw.github.com/projectblacklight/blacklight/master/template.demo.rb
|
46
|
-
create
|
47
|
-
create README.rdoc
|
48
|
-
create Rakefile
|
49
|
-
create config.ru
|
50
|
-
create .gitignore
|
51
|
-
create Gemfile
|
52
|
-
create app
|
53
|
-
create app/assets/javascripts/application.js
|
54
|
-
create app/assets/stylesheets/application.css
|
55
|
-
create app/controllers/application_controller.rb
|
56
|
-
create app/helpers/application_helper.rb
|
57
|
-
create app/views/layouts/application.html.erb
|
58
|
-
create app/assets/images/.keep
|
59
|
-
create app/mailers/.keep
|
60
|
-
create app/models/.keep
|
61
|
-
create app/controllers/concerns/.keep
|
62
|
-
|
63
|
-
.
|
64
|
-
.
|
65
|
-
.
|
66
|
-
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled
|
67
|
-
gem is installed.
|
68
|
-
$ cd search_app
|
69
|
-
```
|
70
|
-
### What Does the Easy Way Generator Do?
|
71
|
-
When you run the Rails generator for a new application, you can pass in the name of a file of template commands to be run after the base generator runs. The template file above runs through steps 2-5 of the 'Hard Way' below.
|
72
|
-
|
73
|
-
## Creating a new application the hard way
|
74
|
-
|
75
|
-
1. Create a new, blank Rails application
|
76
|
-
|
77
|
-
```console
|
78
|
-
$ rails new my_new_blacklightapp
|
79
|
-
$ cd my_new_blacklightapp
|
80
|
-
...
|
81
|
-
```
|
82
|
-
|
83
|
-
2. Append these lines to your application's `Gemfile`
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
gem 'blacklight', ">= 5.3.0"
|
87
|
-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
88
|
-
```
|
89
|
-
|
90
|
-
Especially if you are running on Linux, you may have to add `gem 'therubyracer'` to your gemfile, to get a Javascript runtime needed by the asset pipeline.
|
91
|
-
|
92
|
-
then, update the bundle
|
93
|
-
|
94
|
-
```bash
|
95
|
-
$ bundle install
|
96
|
-
```
|
97
|
-
|
98
|
-
3. Install blacklight using Devise for user authentication:
|
99
|
-
|
100
|
-
```bash
|
101
|
-
$ rails generate blacklight:install --devise --marc --jettywrapper
|
102
|
-
```
|
103
|
-
Including `--devise` will also generate devise-based Users into your application. If you would prefer to integrate with an alternative user authentication provider, see the [[User Authentication]] documentation.
|
104
|
-
|
105
|
-
Including `--marc` will also generate `blacklight-marc` into your application, which adds library-specific functionality out-of-the-box.
|
106
|
-
|
107
|
-
4. Run your database migrations to create Blacklight's database tables:
|
108
|
-
|
109
|
-
```console
|
110
|
-
$ rake db:migrate
|
111
|
-
```
|
112
|
-
|
113
|
-
|
114
|
-
5. For the initial install of Blacklight you may need to download Jetty by running before starting it:
|
115
|
-
|
116
|
-
```console
|
117
|
-
$ rake jetty:clean
|
118
|
-
```
|
119
|
-
## Easy or Hard: After creating your new application
|
120
|
-
1. Make sure your Solr server is running. If you installed the Blacklight using the `--jettywrapper` option, you can start the Jetty/Solr server using:
|
121
|
-
|
122
|
-
```console
|
123
|
-
$ rake jetty:start
|
124
|
-
```
|
125
|
-
You should be able to navigate to Solr at http://localhost:8983/solr/#/blacklight-core/query
|
126
|
-
|
127
|
-
2. Index some data. You can index test the MARC records provided with Blacklight by running:
|
128
|
-
|
129
|
-
```console
|
130
|
-
$ rake solr:marc:index_test_data
|
131
|
-
```
|
132
|
-
Depending on the version of Solr you're using, you may see a warning that can be safely ignored:
|
133
|
-
|
134
|
-
```console
|
135
|
-
Warning: Specifying binary request handling from a Solr Server that doesn't support it. Enable it in the solrconfig file for that server.
|
136
|
-
```
|
137
|
-
3. Start up your application
|
138
|
-
|
139
|
-
```console
|
140
|
-
$ rails server
|
141
|
-
```
|
142
|
-
|
143
|
-
Visit the catalog at [[http://localhost:3000/catalog]].
|
144
|
-
|
145
|
-
![Blacklight Home Page](https://f.cloud.github.com/assets/111218/2059077/5f10e090-8b95-11e3-9cac-72d8e0e5968e.png)
|
146
|
-
|
147
|
-
You should see the Blacklight interface with 30 MARC records for testing. Additional MARC records are available from the [[blacklight-data|https://github.com/projectblacklight/blacklight-data]] repository. These can be ingested into Solr using SolrMarc,
|
148
|
-
|
149
|
-
```console
|
150
|
-
$ rake solr:marc:index MARC_FILE=(path to file)
|
151
|
-
```
|
152
|
-
|
153
|
-
See [[Configuring and Customizing Blacklight]] for information about how to customize the Blacklight user interface, search experience, and more.
|
data/doc/README_SOLR.md
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
#Solr in Blacklight
|
2
|
-
|
3
|
-
##Setting up Solr
|
4
|
-
|
5
|
-
Blacklight uses Solr as its "search engine".
|
6
|
-
More information about Solr is available at the Solr web site ( http://lucene.apache.org/solr/)
|
7
|
-
|
8
|
-
There are three sections to this document:
|
9
|
-
* Getting Solr
|
10
|
-
* Configuring Solr
|
11
|
-
* schema.xml
|
12
|
-
* solrconfig.xml
|
13
|
-
* SolrMARC
|
14
|
-
|
15
|
-
### Getting Solr
|
16
|
-
Blacklight distributes a pre-configured version of Solr (with the Jetty
|
17
|
-
container) as [[blacklight-jetty|https://github.com/projectblacklight/blacklight-jetty/tags]].
|
18
|
-
|
19
|
-
You can also use an existing Solr index (with some minor modifications).
|
20
|
-
If you want to start from a new version of Solr, follow the directions from the [[Solr tutorial|http://lucene.apache.org/solr/tutorial.html]]
|
21
|
-
|
22
|
-
You should now have a usable copy of Solr.
|
23
|
-
|
24
|
-
### Configuring Solr
|
25
|
-
####Solr Schema.xml
|
26
|
-
|
27
|
-
Between the `schema.xml` and `solrconfig.xml` you can change and tune the search behavior following directions from the [[Solr wiki|http://wiki.apache.org/solr/]]. Solr comes with example schema and solrconfig files, which you can use as a starting point for configuring your local Solr application.
|
28
|
-
|
29
|
-
Blacklight expects a uniqueKey field within your Solr index,
|
30
|
-
traditionally called `id`. The name of the unique key field can be
|
31
|
-
configured in your application's `SolrDocument`.
|
32
|
-
|
33
|
-
##### Blacklight community "best practices"
|
34
|
-
|
35
|
-
Solr uses a schema.xml file to define document fields (among other things). These fields store data for searching and for result display. You can find the example/solr/conf/schema.xml file in the Solr distribution you just downloaded and uncompressed.
|
36
|
-
|
37
|
-
Documentation about the Solr schema.xml file is available at (http://wiki.apache.org/solr/SchemaXml).
|
38
|
-
|
39
|
-
The default schema.xml file comes with some preset fields made to work with
|
40
|
-
the example data. If you don't already have a schema.xml setup, we
|
41
|
-
recommend using a simplified "fields" section like this:
|
42
|
-
```xml
|
43
|
-
<fields>
|
44
|
-
<field name="id" type="string" indexed="true" stored="true" required="true" />
|
45
|
-
<field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
|
46
|
-
<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
|
47
|
-
<field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/>
|
48
|
-
<dynamicField name="*_i" type="sint" indexed="true" stored="true"/>
|
49
|
-
<dynamicField name="*_s" type="string" indexed="true" stored="true" multiValued="true"/>
|
50
|
-
<dynamicField name="*_l" type="slong" indexed="true" stored="true"/>
|
51
|
-
<dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="true"/>
|
52
|
-
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
|
53
|
-
<dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/>
|
54
|
-
<dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/>
|
55
|
-
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
|
56
|
-
<dynamicField name="random*" type="random" />
|
57
|
-
<dynamicField name="*_facet" type="string" indexed="true" stored="true" multiValued="true" />
|
58
|
-
<dynamicField name="*_display" type="string" indexed="false" stored="true" />
|
59
|
-
</fields>
|
60
|
-
```
|
61
|
-
|
62
|
-
Additionally, replace all of the tags after the "fields" section, and before
|
63
|
-
the `</schema>` tag with this:
|
64
|
-
|
65
|
-
```xml
|
66
|
-
<uniqueKey>id</uniqueKey>
|
67
|
-
<defaultSearchField>text</defaultSearchField>
|
68
|
-
<solrQueryParser defaultOperator="OR"/>
|
69
|
-
<copyField source="*_facet" dest="text"/>
|
70
|
-
```
|
71
|
-
|
72
|
-
Now you have a basic schema.xml file ready. Other fields can be specified, including a primary document title (`title_display`) and format (`format`), but these are easily configured in your application's `CatalogController`.
|
73
|
-
|
74
|
-
Fields that are "indexed" are searchable.
|
75
|
-
|
76
|
-
Fields that are "stored" are can be viewed/displayed from the Solr search
|
77
|
-
results.
|
78
|
-
|
79
|
-
The fields with asterisks ('*') in their names are "dynamic" fields. These
|
80
|
-
allow you to create arbitrary tags at index time.
|
81
|
-
|
82
|
-
The *_facet field can be used for creating your facets. When you index,
|
83
|
-
simply define a field with _facet on the end:
|
84
|
-
category_facet
|
85
|
-
|
86
|
-
The *_display field can be used for storing text that doesn't need to be
|
87
|
-
indexed. An example would be the raw MARC for a record's detail view:
|
88
|
-
raw_marc_display
|
89
|
-
|
90
|
-
For text that will be queried (and possibly displayed), use the *_t type
|
91
|
-
field for tokenized text (text broken into pieces/words) or the *_s type
|
92
|
-
for queries that should exactly match the field contents:
|
93
|
-
description_t
|
94
|
-
url_s
|
95
|
-
|
96
|
-
The Blacklight application is generic enough to work with any Solr schema, but to
|
97
|
-
manipulate the search results and single record displays, you'll need to know the
|
98
|
-
stored fields in your indexed documents.
|
99
|
-
|
100
|
-
For more information, refer to the Solr documentation:
|
101
|
-
http://wiki.apache.org/solr/SchemaXml
|
102
|
-
|
103
|
-
|
104
|
-
#####solrconfig.xml
|
105
|
-
|
106
|
-
Solr uses the solrconfig.xml file to define searching configurations, set cache options, etc.
|
107
|
-
You can find the examples/solr/conf/solrconfig.xml in the distribution directory you just uncompressed.
|
108
|
-
|
109
|
-
Documentation about the solrconfig.xml file is available at (http://wiki.apache.org/solr/SolrConfigXml).
|
110
|
-
|
111
|
-
Blacklight expects two request handlers to be defined -- one to handle
|
112
|
-
general search requests and one to handle single-document lookup. The
|
113
|
-
names of these request handlers are configurable, but are called
|
114
|
-
"search" and "document" respectively, out of the box.
|
115
|
-
|
116
|
-
|
117
|
-
#####Solr Search Request Handlers
|
118
|
-
|
119
|
-
When Blacklight does a collection search, it sends a request to a Solr
|
120
|
-
request handler named "search". The most important settings in this handler
|
121
|
-
definition are the "fl" param (field list) and the facet params.
|
122
|
-
|
123
|
-
The "fl" param specifies which fields are returned in a Solr response.
|
124
|
-
The facet related params set up the faceting mechanism.
|
125
|
-
|
126
|
-
Find out more about the basic params:
|
127
|
-
http://wiki.apache.org/solr/DisMaxRequestHandler
|
128
|
-
|
129
|
-
Find out more about the faceting params:
|
130
|
-
http://wiki.apache.org/solr/SimpleFacetParameters
|
131
|
-
|
132
|
-
|
133
|
-
######How the "fl" param works in Blacklight's request handlers
|
134
|
-
|
135
|
-
Blacklight comes with a set of "default" views for rendering each document
|
136
|
-
in a search results page. This view simply loops through all of the fields
|
137
|
-
returned in each document in the Solr response. The "fl" (field list) param
|
138
|
-
tells Solr which fields to include in the documents in the response ...
|
139
|
-
and these are the fields rendered in the Blacklight default views.
|
140
|
-
Thus, the fields you want rendered must be specified in "fl". Note that
|
141
|
-
only "stored" fields will be available; if you want a field to be rendered
|
142
|
-
in the result, it must be "stored" per the field definition in schema.xml.
|
143
|
-
|
144
|
-
The "fl" parameter definition in the "search" handler looks like this:
|
145
|
-
```xml
|
146
|
-
<str name="fl">id,score,author_display,(....lots of other fields)</str>
|
147
|
-
```
|
148
|
-
You may also use an asterisk plus "score":
|
149
|
-
```xml
|
150
|
-
<str name="fl">*,score</str>
|
151
|
-
```
|
152
|
-
|
153
|
-
######How the facet params work in Blacklight's request handlers
|
154
|
-
|
155
|
-
In the search results view, Blacklight will look into the Solr response for
|
156
|
-
facets. If you specify any facet.field params in your "search" handler,
|
157
|
-
they will automatically get displayed in the facets list:
|
158
|
-
```xml
|
159
|
-
<str name="facet.field">format</str>
|
160
|
-
<str name="facet.field">language_facet</str>
|
161
|
-
```
|
162
|
-
|
163
|
-
|
164
|
-
#####Blacklight's "search" request handler: for search results
|
165
|
-
|
166
|
-
When Blacklight displays a list of search results, it uses a Solr request
|
167
|
-
handler named "search." Thus, the field list (fl param) for the "search"
|
168
|
-
request handler should be tailored to what will be displayed in a search
|
169
|
-
results page. Generally, this will not include fields containing a large
|
170
|
-
quantity of text. The facet param should contain the facets to be
|
171
|
-
displayed with the search results.
|
172
|
-
```xml
|
173
|
-
|
174
|
-
<requestHandler name="search" class="solr.SearchHandler" >
|
175
|
-
<lst name="defaults">
|
176
|
-
<str name="defType">dismax</str>
|
177
|
-
<str name="echoParams">explicit</str>
|
178
|
-
<!-- list fields to be returned in the "fl" param -->
|
179
|
-
<str name="fl">*,score</str>
|
180
|
-
|
181
|
-
<str name="facet">on</str>
|
182
|
-
<str name="facet.mincount">1</str>
|
183
|
-
<str name="facet.limit">10</str>
|
184
|
-
|
185
|
-
<!-- list fields to be displayed as facets here. -->
|
186
|
-
<str name="facet.field">format</str>
|
187
|
-
<str name="facet.field">language_facet</str>
|
188
|
-
|
189
|
-
<str name="q.alt">*:*</str>
|
190
|
-
</lst>
|
191
|
-
</requestHandler>
|
192
|
-
```
|
193
|
-
|
194
|
-
#####Blacklight's "document" request handler: for a single record
|
195
|
-
|
196
|
-
When Blacklight displays a single record it uses a Solr request handler
|
197
|
-
named "document". The "document" handler doesn't necessarily need to be
|
198
|
-
different than the "search" handler, but it can be used to control which
|
199
|
-
fields are available to display a single document. In the example below,
|
200
|
-
there is no faceting set (facets are not displayed with a single record)
|
201
|
-
and the "rows" param is set to 1 (since there will only be a single record).
|
202
|
-
Also, the field list ("fl" param) could include fields containing large
|
203
|
-
text values if they are desired for record display. Is is acceptable to
|
204
|
-
include large amounts of data, because this handler should only be used
|
205
|
-
to query for one document:
|
206
|
-
|
207
|
-
<requestHandler name="document" class="solr.SearchHandler">
|
208
|
-
<lst name="defaults">
|
209
|
-
<str name="echoParams">explicit</str>
|
210
|
-
<str name="fl">*</str>
|
211
|
-
<str name="rows">1</str>
|
212
|
-
<str name="q">{!raw f=id v=$id}</str>
|
213
|
-
<!-- use id=blah instead of q=id:blah -->
|
214
|
-
</lst>
|
215
|
-
</requestHandler>
|
216
|
-
|
217
|
-
A Solr query for a single record might look like this:
|
218
|
-
http://(yourSolrBaseUrl)/solr/select?id=my_doc_id&qt=document
|
219
|
-
|
220
|
-
|
221
|
-
####Blacklight Solr Schema and Solrconfig File Templates
|
222
|
-
|
223
|
-
Blacklight provides schema.xml and solrconfig.xml files as starting points:
|
224
|
-
|
225
|
-
https://github.com/projectblacklight/blacklight-jetty/blob/master/solr/blacklight-core/conf/schema.xml
|
226
|
-
|
227
|
-
https://github.com/projectblacklight/blacklight-jetty/blob/master/solr/blacklight-core/conf/solrconfig.xml
|
228
|
-
|
229
|
-
#SolrMARC: from Marc data to Solr documents
|
230
|
-
|
231
|
-
The SolrMARC project is designed to create a Solr index from raw MARC data.
|
232
|
-
It can be configured easily and used with the basic parsing and indexing
|
233
|
-
supplied. It is also readily customized for a site's unique requirements.
|
234
|
-
|
235
|
-
The project software and documentation is available at [[http://code.google.com/p/solrmarc]]
|
236
|
-
|
237
|
-
Blacklight comes with an embedded SolrMarc, with some default config that matches the default Blacklight setup, and provides some rake tasks to easily index docs with SolrMarc according to your app's environment. There is no need to manually install/configure SolrMarc yourself. From your application's home directory simply run:
|
238
|
-
```bash
|
239
|
-
rake solr:marc:index:info
|
240
|
-
```
|
241
|
-
to see options. Run `rake solr:marc:index` to actually do indexing. Like all rake tasks, by default this will use your 'development' environment; add "RAILS_ENV=production" to instead index to the solr you've labelled production in your config/solr.yml file.
|
242
|
-
|
243
|
-
The solrmarc config files are in your app's config/SolrMarc directory, you can edit them there for local config.
|
244
|
-
|
245
|
-
If you'd like to use a different or more recent version of SolrMarc.jar, you can put it in your app at ./solr_marc/SolrMarc.jar, and the built-in rake tasks will use your local SolrMarc.jar instead of the one bundled with Blacklight.
|