solr_ead 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rvmrc +48 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +178 -0
- data/Rakefile +5 -0
- data/config/solr.yml +6 -0
- data/lib/ead_mapper.rb +22 -0
- data/lib/solr_ead/behaviors.rb +124 -0
- data/lib/solr_ead/component.rb +74 -0
- data/lib/solr_ead/document.rb +72 -0
- data/lib/solr_ead/indexer.rb +128 -0
- data/lib/solr_ead/om_behaviors.rb +38 -0
- data/lib/solr_ead/railtie.rb +7 -0
- data/lib/solr_ead/version.rb +3 -0
- data/lib/solr_ead.rb +20 -0
- data/lib/tasks/solr_ead.rake +30 -0
- data/lib/terminology_based_solrizer.rb +9 -0
- data/solr_ead.gemspec +27 -0
- data/spec/behaviors_spec.rb +105 -0
- data/spec/component_spec.rb +32 -0
- data/spec/document_spec.rb +80 -0
- data/spec/fixtures/ARC-0005.xml +1301 -0
- data/spec/fixtures/component_template.xml +19 -0
- data/spec/fixtures/ead_sample.xml +455 -0
- data/spec/fixtures/ead_template.xml +28 -0
- data/spec/fixtures/pp002010.xml +1139 -0
- data/spec/indexer_spec.rb +112 -0
- data/spec/spec_helper.rb +30 -0
- metadata +198 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@solr_ead"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.14.3 (version)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Adam Wead
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
# SolrEad
|
2
|
+
|
3
|
+
SolrEad is a gem that indexes your ead documents into Solr. From there, you can use other
|
4
|
+
Solr-based applications to search and display your finding aids. It originated as some
|
5
|
+
code that I used to index ead into Blacklight, but this gem does not require you to use
|
6
|
+
Blacklight. You can use this gem with any Solr-based app.
|
7
|
+
|
8
|
+
SolrEad uses OM (Opinionated Metadata) to define terms in your ead xml, then uses Solrizer
|
9
|
+
to create solr fields from those terms. An indexer is included that has basic create,
|
10
|
+
update and delete methods for getting your documents in and out of solr via the RSolr gem.
|
11
|
+
|
12
|
+
The default term definitions are all based on eads created with Archivist's Toolkit, so
|
13
|
+
whatever conventions AT has in its ead will be manifested here. However, you are able to
|
14
|
+
override this definitions with your own to meet any specific local needs.
|
15
|
+
|
16
|
+
## Indexing
|
17
|
+
|
18
|
+
SolrEad's default way of indexing a single ead document is to create one solr document for
|
19
|
+
the initial part of the ead and then separate documents for each component node. You may
|
20
|
+
also elect to use a simple indexing option which creates only one solr document per ead
|
21
|
+
document.
|
22
|
+
|
23
|
+
For more information on indexing, see the documentation for SolrEad::Indexer.
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
gem 'solr_ead'
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle install
|
34
|
+
|
35
|
+
Or install it yourself:
|
36
|
+
|
37
|
+
$ gem install solr_ead
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
$ rake solr_ead:index FILE=/path/to/your/ead.xml
|
42
|
+
|
43
|
+
You can also do this via the command line:
|
44
|
+
|
45
|
+
> indexer = SolrEad::Indexer.new
|
46
|
+
> indexer.create(File.new("path/to/your/ead.xml))
|
47
|
+
|
48
|
+
### Usage with Blacklight
|
49
|
+
|
50
|
+
This code originated in a Blacklight application and some of its default solr fields
|
51
|
+
reflect a Blacklight-style solr implementation. For example, certain facet fields such as
|
52
|
+
subject_topic_facet and title_display will appear in your solr index by default. If you
|
53
|
+
are trying out the gem within a default Blacklight installation, you should be able to
|
54
|
+
index your ead without any modifications. However, the only fields that will appear in
|
55
|
+
your search results will be format and title. In order to make this into working
|
56
|
+
solution, you'll need to modify both the definitions of documents and components within
|
57
|
+
SolrEad and configure Blacklight's own display and facet fields accordingly.
|
58
|
+
|
59
|
+
## Applications
|
60
|
+
|
61
|
+
SolrEad is intended to work at the indexing layer of an application, but it can also work
|
62
|
+
at the display/presentation layer as well. You can use the solr fields defined in your OM
|
63
|
+
terminology for display; however, formatting information such as italics and boldface is
|
64
|
+
not preserved from the original EAD xml.
|
65
|
+
|
66
|
+
For those that need to preserve the formatting of their finding aids, you can use XSLT to
|
67
|
+
process your EAD for display in your application and use SolrEad to index your finding
|
68
|
+
aids for searching.
|
69
|
+
|
70
|
+
When creating display pages of your finding aids, you can either use "ready-made" html
|
71
|
+
pages created using XSLT, or create the html when the page is requested. If you opt for
|
72
|
+
the latter, you can store the ead xml in a solr field. To do this, add a new solr field
|
73
|
+
under the to_solr method of your OM terminology for the ead document:
|
74
|
+
|
75
|
+
solr_doc.merge!({"xml_display" => self.to_xml})
|
76
|
+
|
77
|
+
This will create the solr field "xml_display" containing the complete ead xml. Then you
|
78
|
+
will be able to apply any xslt processing you wish. Other solutions are possible using
|
79
|
+
xml from the document as well as the component, depending on the needs of your
|
80
|
+
application.
|
81
|
+
|
82
|
+
## Customization
|
83
|
+
|
84
|
+
Chances are the default definitions are not sufficient for your needs. If you want to
|
85
|
+
create your own definitions for documents and components, here's what you can do.
|
86
|
+
|
87
|
+
### Writing a custom document definition
|
88
|
+
|
89
|
+
Under lib or another directory of your choice, create the file custom_document.rb with the
|
90
|
+
following content:
|
91
|
+
|
92
|
+
class CustomDocument < SolrEad::Document
|
93
|
+
|
94
|
+
set_terminology do |t|
|
95
|
+
t.root(:path="ead", :index_as = [:not_searchable])
|
96
|
+
t.eadid
|
97
|
+
|
98
|
+
# Add additional term definitions here
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# Optionally, you may tweak other solr fields here. Otherwise, you can leave this
|
103
|
+
# method out of your definition.
|
104
|
+
def to_solr(solr_doc = Hash.new)
|
105
|
+
super(solr_doc)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
From the console, index you ead document using your new definition.
|
111
|
+
|
112
|
+
> file = "path/to/ead.xml"
|
113
|
+
> indexer = SolrEad::Indexer.new(:document=>"CustomDocument")
|
114
|
+
> indexer.create(file)
|
115
|
+
|
116
|
+
### Adding custom methods
|
117
|
+
|
118
|
+
Suppose you want to add some custom methods that perform additional manipulations of
|
119
|
+
your solr fields after they've been pulled from your ead. You can create a module
|
120
|
+
for all your specialized methods and add it to your ead document.
|
121
|
+
|
122
|
+
module MyEadBehaviors
|
123
|
+
|
124
|
+
def special_process(field)
|
125
|
+
# manipulate your field here
|
126
|
+
return field
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
Then, include your module in your own custom document and call the method during to_solr:
|
132
|
+
|
133
|
+
class CustomDocument < SolrEad::Document
|
134
|
+
|
135
|
+
include MyEadBehaviors
|
136
|
+
|
137
|
+
# terminology goes here...
|
138
|
+
|
139
|
+
def to_solr(solr_doc = Hash.new)
|
140
|
+
super(solr_doc)
|
141
|
+
solr_doc.merge!({"solr_field" => special_process(self.field_name)})
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
Your solr document will now include the field "solr_field" that has taken the term
|
147
|
+
"field_name" and processed it with the special_process method.
|
148
|
+
|
149
|
+
### Solr schema configurations
|
150
|
+
|
151
|
+
SolrEad is designed to work with the solr jetty application that comes with Blacklight.
|
152
|
+
However, this doesn't prevent you from using your own solr application. You can alter the
|
153
|
+
way SolrEad creates its solr fields by creating your own mapper. See the ead_mapper.rb
|
154
|
+
file for more info and the solrizer gem for more information on configuring how SolrEad
|
155
|
+
creates solr fields.
|
156
|
+
|
157
|
+
By default, SolrEad will display series and subseries component documents. You may,
|
158
|
+
however, want to surpress this from search results. To do this, add the following line to
|
159
|
+
your solrconfig.xml file, under the "search" request handler:
|
160
|
+
|
161
|
+
<lst name="appends"><str name="fq">-component_children_b:[TRUE TO *]</str></lst>
|
162
|
+
|
163
|
+
## Contributing
|
164
|
+
|
165
|
+
If you have questions or have specific needs, let me know. If you have other ideas or
|
166
|
+
solutions, please contribute code!
|
167
|
+
|
168
|
+
1. Fork SolrEad
|
169
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
170
|
+
3. Add your code
|
171
|
+
4. Add tests for your code and make sure it doesn't break existing features
|
172
|
+
5. Commit your changes (`git commit -am 'Added some feature'`)
|
173
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
174
|
+
7. Create new Pull Request
|
175
|
+
|
176
|
+
## Copyright
|
177
|
+
|
178
|
+
Copyright (c) 2012 Adam Wead. See LICENSE for details.
|
data/Rakefile
ADDED
data/config/solr.yml
ADDED
data/lib/ead_mapper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class EadMapper < Solrizer::FieldMapper
|
2
|
+
|
3
|
+
id_field 'id'
|
4
|
+
index_as :searchable, :default => true do |t|
|
5
|
+
t.default :suffix => '_t'
|
6
|
+
t.date :suffix => '_dt'
|
7
|
+
t.string :suffix => '_t'
|
8
|
+
t.text :suffix => '_t'
|
9
|
+
t.symbol :suffix => '_s'
|
10
|
+
t.integer :suffix => '_i'
|
11
|
+
t.long :suffix => '_l'
|
12
|
+
t.boolean :suffix => '_b'
|
13
|
+
t.float :suffix => '_f'
|
14
|
+
t.double :suffix => '_d'
|
15
|
+
end
|
16
|
+
index_as :displayable, :suffix => '_display'
|
17
|
+
index_as :facetable, :suffix => '_facet'
|
18
|
+
index_as :sortable, :suffix => '_sort'
|
19
|
+
index_as :unstemmed_searchable, :suffix => '_unstem_search'
|
20
|
+
index_as :string, :suffix => '_s'
|
21
|
+
index_as :z, :suffix => '_z'
|
22
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require "sanitize"
|
2
|
+
|
3
|
+
module SolrEad::Behaviors
|
4
|
+
|
5
|
+
# Takes a file as its input and returns a Nokogiri::XML::NodeSet of component <c> nodes
|
6
|
+
#
|
7
|
+
# It'll make an attempt at substituting numbered component levels for non-numbered
|
8
|
+
# ones.
|
9
|
+
def components(file)
|
10
|
+
raw = File.read(file).gsub!(/xmlns=".*"/, '')
|
11
|
+
raw.gsub!(/c[0-9]{2,2}/,"c")
|
12
|
+
xml = Nokogiri::XML(raw)
|
13
|
+
return xml.xpath("//c")
|
14
|
+
end
|
15
|
+
|
16
|
+
# Used in conjunction with #components, this takes a single Nokogiri::XML::Element
|
17
|
+
# representing an <c> node from an ead document, and returns a Nokogiri::XML::Document
|
18
|
+
# with any child <c> nodes removed.
|
19
|
+
# == Example
|
20
|
+
# If I input this Nokogiri::XML::Element
|
21
|
+
# <c>
|
22
|
+
# <did>etc</did>
|
23
|
+
# <scopecontent>etc</scopecontent>
|
24
|
+
# <c>etc</c>
|
25
|
+
# <c>etc</c>
|
26
|
+
# </c>
|
27
|
+
# Then I should get back the following Nokogiri::XML::Document
|
28
|
+
# <c>
|
29
|
+
# <did>etc</did>
|
30
|
+
# <scopecontent>etc</scopecontent>
|
31
|
+
# </c>
|
32
|
+
def prep(node)
|
33
|
+
part = Nokogiri::XML(node.to_s)
|
34
|
+
part.xpath("/*/c").each { |e| e.remove }
|
35
|
+
return part
|
36
|
+
end
|
37
|
+
|
38
|
+
# Because the solr documents created from individual components have been removed from
|
39
|
+
# the hierarchy of their original ead, we need to be able to reconstruct the order
|
40
|
+
# in which they appeared, as well as their location within the hierarchy.
|
41
|
+
#
|
42
|
+
# This method takes a single Nokogiri::XMl::Node as its argument that represents a
|
43
|
+
# single <c> component node, but with all of this parent nodes still attached. From
|
44
|
+
# there we can determine all of its parent <c> nodes so that we can correctly
|
45
|
+
# reconstruct its placement within the original ead hierarchy.
|
46
|
+
#
|
47
|
+
# The solr fields returned by this method are:
|
48
|
+
#
|
49
|
+
# id:: Unique identifier using the id attribute and the <eadid>
|
50
|
+
# eadid_s:: The <eadid> node of the ead. This is so we know which ead this component belongs to.
|
51
|
+
# parent_id_s:: The id attribute of the parent <c> node
|
52
|
+
# parent_ids_display:: Stored as a display fields so it is not indexed. See parent_id_list for more info.
|
53
|
+
# parent_unittitles_display:: Stored as a display fields so it is not indexed. See parent_id_list for more info.
|
54
|
+
# component_level_i:: numeric level of the component
|
55
|
+
# component_children_b:: Boolean field indicating whether or not the component has any child <c> nodes attached to it
|
56
|
+
#
|
57
|
+
# These fields are used so that we may reconstruct placement of a single component
|
58
|
+
# within the hierarchy of the original ead.
|
59
|
+
def additional_component_fields(node, addl_fields = Hash.new)
|
60
|
+
addl_fields["id"] = [node.xpath("//eadid").text, node.attr("id")].join(":")
|
61
|
+
addl_fields["eadid_s"] = node.xpath("//eadid").text
|
62
|
+
addl_fields["parent_id_s"] = node.parent.attr("id") unless node.parent.attr("id").nil?
|
63
|
+
addl_fields["parent_ids_display"] = parent_id_list(node)
|
64
|
+
addl_fields["parent_unittitles_display"] = parent_unittitle_list(node)
|
65
|
+
addl_fields["component_level_i"] = parent_id_list(node).length + 1
|
66
|
+
addl_fields["component_children_b"] = component_children?(node)
|
67
|
+
return addl_fields
|
68
|
+
end
|
69
|
+
|
70
|
+
# Array of all id attributes from the component's parent <c> nodes, sorted in descending order
|
71
|
+
# This is used to reconstruct the order of component documents that should appear above
|
72
|
+
# a specific item-level component.
|
73
|
+
def parent_id_list(node, results = Array.new)
|
74
|
+
while node.parent.name == "c"
|
75
|
+
parent = node.parent
|
76
|
+
results << parent.attr("id") unless parent.attr("id").nil?
|
77
|
+
node = parent
|
78
|
+
end
|
79
|
+
return results.reverse
|
80
|
+
end
|
81
|
+
|
82
|
+
# Array of all unittitle nodes from the component's parent <c> nodes, sort in descending order
|
83
|
+
# This is useful if you want to display a list of a component's parent containers in
|
84
|
+
# the correct order, ex:
|
85
|
+
# ["Series I", "Subseries a", "Sub-subseries 1"]
|
86
|
+
# From there, you can assemble and display as you like.
|
87
|
+
def parent_unittitle_list(node, results = Array.new)
|
88
|
+
while node.parent.name == "c"
|
89
|
+
parent = node.parent
|
90
|
+
part = Nokogiri::XML(parent.to_xml)
|
91
|
+
results << get_title(part)
|
92
|
+
node = parent
|
93
|
+
end
|
94
|
+
return results.reverse
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_title(xml)
|
98
|
+
title = xml.at("/c/did/unittitle")
|
99
|
+
date = xml.at("/c/did/unitdate")
|
100
|
+
if !title.nil? and !title.content.empty?
|
101
|
+
return ead_clean_xml(title.content)
|
102
|
+
elsif !date.nil? and !date.content.empty?
|
103
|
+
return ead_clean_xml(date.content)
|
104
|
+
else
|
105
|
+
return "[No title available]"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Converts formatting elements in the ead into html tags
|
110
|
+
def ead_clean_xml(string)
|
111
|
+
string.gsub!(/<title/,"<span")
|
112
|
+
string.gsub!(/<\/title/,"</span")
|
113
|
+
string.gsub!(/render=/,"class=")
|
114
|
+
sanitize = Sanitize.clean(string, :elements => ['span'], :attributes => {'span' => ['class']})
|
115
|
+
sanitize.gsub("\n",'').gsub(/\s+/, ' ').strip
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns true or false for a component with attached <c> child nodes.
|
119
|
+
def component_children?(node, t = Array.new)
|
120
|
+
node.children.each { |n| t << n.name }
|
121
|
+
t.include?("c") ? TRUE : FALSE
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class SolrEad::Component
|
2
|
+
|
3
|
+
include OM::XML::Document
|
4
|
+
include Solrizer::XML::TerminologyBasedSolrizer
|
5
|
+
|
6
|
+
# Define each term in your ead that you want put into the solr document
|
7
|
+
set_terminology do |t|
|
8
|
+
t.root(:path=>"c", :index_as => [:not_searchable, :not_displayable])
|
9
|
+
t.ref(:path=>"/c/@id")
|
10
|
+
t.level(:path=>"/c/@level", :index_as => [:facetable])
|
11
|
+
|
12
|
+
t.title(:path=>"unittitle", :attributes=>{ :type => :none }, :index_as=>[:searchable, :displayable])
|
13
|
+
|
14
|
+
# Default facets
|
15
|
+
t.corpname(:index_as=>[:facetable])
|
16
|
+
t.famname(:index_as=>[:facetable])
|
17
|
+
t.genreform(:index_as=>[:facetable])
|
18
|
+
t.geogname(:index_as=>[:facetable])
|
19
|
+
t.name(:index_as=>[:facetable])
|
20
|
+
t.persname(:index_as=>[:facetable])
|
21
|
+
t.subject(:index_as=>[:facetable])
|
22
|
+
|
23
|
+
# Archival material
|
24
|
+
t.container(:attributes=>{ :type => "Box" }, :index_as => [:not_searchable, :not_displayable]) {
|
25
|
+
t.label(:path=>{ :attribute=>"label" }, :index_as => [:facetable])
|
26
|
+
}
|
27
|
+
t.material(:proxy=>[:container, :label])
|
28
|
+
|
29
|
+
# These terms are proxied to match with Blacklight's default facets, but otherwise
|
30
|
+
# you can remove them or rename the above facet terms to match with your solr
|
31
|
+
# implementation.
|
32
|
+
t.subject_geo(:proxy=>[:geogname])
|
33
|
+
t.subject_topic(:proxy=>[:subject])
|
34
|
+
|
35
|
+
t.accessrestrict(:path=>"accessrestrict/p")
|
36
|
+
t.accessrestrict_heading(:path=>"accessrestrict/head", :index_as=>[:not_searchable, :displayable])
|
37
|
+
t.accruals(:path=>"accruals/p")
|
38
|
+
t.accruals_heading(:path=>"accruals/head", :index_as=>[:not_searchable, :displayable])
|
39
|
+
t.acqinfo(:path=>"acqinfo/p")
|
40
|
+
t.acqinfo_heading(:path=>"acqinfo/head", :index_as=>[:not_searchable, :displayable])
|
41
|
+
t.altformavail(:path=>"altformavail/p")
|
42
|
+
t.altformavail_heading(:path=>"altformavail/head", :index_as=>[:not_searchable, :displayable])
|
43
|
+
t.appraisal(:path=>"appraisal/p")
|
44
|
+
t.appraisal_heading(:path=>"appraisal/head", :index_as=>[:not_searchable, :displayable])
|
45
|
+
t.arrangement(:path=>"arrangement/p")
|
46
|
+
t.arrangement_heading(:path=>"arrangement/head", :index_as=>[:not_searchable, :displayable])
|
47
|
+
t.custodhist(:path=>"custodhist/p")
|
48
|
+
t.custodhist_heading(:path=>"custodhist/head", :index_as=>[:not_searchable, :displayable])
|
49
|
+
t.fileplan(:path=>"fileplan/p")
|
50
|
+
t.fileplan_heading(:path=>"fileplan/head", :index_as=>[:not_searchable, :displayable])
|
51
|
+
t.originalsloc(:path=>"originalsloc/p")
|
52
|
+
t.originalsloc_heading(:path=>"originalsloc/head", :index_as=>[:not_searchable, :displayable])
|
53
|
+
t.phystech(:path=>"phystech/p")
|
54
|
+
t.phystech_heading(:path=>"phystech/head", :index_as=>[:not_searchable, :displayable])
|
55
|
+
t.processinfo(:path=>"processinfo/p")
|
56
|
+
t.processinfo_heading(:path=>"processinfo/head", :index_as=>[:not_searchable, :displayable])
|
57
|
+
t.relatedmaterial(:path=>"relatedmaterial/p")
|
58
|
+
t.relatedmaterial_heading(:path=>"relatedmaterial/head", :index_as=>[:not_searchable, :displayable])
|
59
|
+
t.separatedmaterial(:path=>"separatedmaterial/p")
|
60
|
+
t.separatedmaterial_heading(:path=>"separatedmaterial/head", :index_as=>[:not_searchable, :displayable])
|
61
|
+
t.scopecontent(:path=>"scopecontent/p")
|
62
|
+
t.scopecontent_heading(:path=>"scopecontent/head", :index_as=>[:not_searchable, :displayable])
|
63
|
+
t.userestrict(:path=>"userestrict/p")
|
64
|
+
t.userestrict_heading(:path=>"userestrict/head", :index_as=>[:not_searchable, :displayable])
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_solr(solr_doc = Hash.new)
|
69
|
+
super(solr_doc)
|
70
|
+
solr_doc.merge!({"format" => "Archival Item"})
|
71
|
+
solr_doc.merge!({"heading_display" => [ solr_doc["parent_unittitle_list_t"], self.title.first ].join(" >> ") })
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class SolrEad::Document
|
2
|
+
|
3
|
+
include OM::XML::Document
|
4
|
+
include Solrizer::XML::TerminologyBasedSolrizer
|
5
|
+
include SolrEad::OmBehaviors
|
6
|
+
|
7
|
+
# Define each term in your ead that you want put into the solr document
|
8
|
+
set_terminology do |t|
|
9
|
+
t.root(:path=>"ead", :index_as => [:not_searchable])
|
10
|
+
|
11
|
+
t.eadid
|
12
|
+
t.corpname(:index_as=>[:facetable])
|
13
|
+
t.famname(:index_as=>[:facetable])
|
14
|
+
t.genreform(:index_as=>[:facetable])
|
15
|
+
t.geogname(:index_as=>[:facetable])
|
16
|
+
t.name(:index_as=>[:facetable])
|
17
|
+
t.persname(:index_as=>[:facetable])
|
18
|
+
t.subject(:index_as=>[:facetable])
|
19
|
+
|
20
|
+
# These terms are proxied to match with Blacklight's default facets, but otherwise
|
21
|
+
# you can remove them or rename the above facet terms to match with your solr
|
22
|
+
# implementation.
|
23
|
+
t.subject_geo(:proxy=>[:geogname])
|
24
|
+
t.subject_topic(:proxy=>[:subject])
|
25
|
+
|
26
|
+
t.title(:path=>"titleproper", :attributes=>{ :type => :none }, :index_as=>[:searchable, :displayable])
|
27
|
+
t.title_filing(:path=>"titleproper", :attributes=>{ :type => "filing" }, :index_as=>[:not_searchable, :sortable])
|
28
|
+
|
29
|
+
# General field available within archdesc
|
30
|
+
t.accessrestrict(:path=>"archdesc/accessrestrict/p")
|
31
|
+
t.accessrestrict_heading(:path=>"archdesc/accessrestrict/head", :index_as=>[:not_searchable, :displayable])
|
32
|
+
t.accruals(:path=>"archdesc/accruals/p")
|
33
|
+
t.accruals_heading(:path=>"archdesc/accruals/head", :index_as=>[:not_searchable, :displayable])
|
34
|
+
t.acqinfo(:path=>"archdesc/acqinfo/p")
|
35
|
+
t.acqinfo_heading(:path=>"archdesc/acqinfo/head", :index_as=>[:not_searchable, :displayable])
|
36
|
+
t.altformavail(:path=>"archdesc/altformavail/p")
|
37
|
+
t.altformavail_heading(:path=>"archdesc/altformavail/head", :index_as=>[:not_searchable, :displayable])
|
38
|
+
t.appraisal(:path=>"archdesc/appraisal/p")
|
39
|
+
t.appraisal_heading(:path=>"archdesc/appraisal/head", :index_as=>[:not_searchable, :displayable])
|
40
|
+
t.arrangement(:path=>"archdesc/arrangement/p")
|
41
|
+
t.arrangement_heading(:path=>"archdesc/arrangement/head", :index_as=>[:not_searchable, :displayable])
|
42
|
+
t.custodhist(:path=>"archdesc/custodhist/p")
|
43
|
+
t.custodhist_heading(:path=>"archdesc/custodhist/head", :index_as=>[:not_searchable, :displayable])
|
44
|
+
t.fileplan(:path=>"archdesc/fileplan/p")
|
45
|
+
t.fileplan_heading(:path=>"archdesc/fileplan/head", :index_as=>[:not_searchable, :displayable])
|
46
|
+
t.originalsloc(:path=>"archdesc/originalsloc/p")
|
47
|
+
t.originalsloc_heading(:path=>"archdesc/originalsloc/head", :index_as=>[:not_searchable, :displayable])
|
48
|
+
t.phystech(:path=>"archdesc/phystech/p")
|
49
|
+
t.phystech_heading(:path=>"archdesc/phystech/head", :index_as=>[:not_searchable, :displayable])
|
50
|
+
t.processinfo(:path=>"archdesc/processinfo/p")
|
51
|
+
t.processinfo_heading(:path=>"archdesc/processinfo/head", :index_as=>[:not_searchable, :displayable])
|
52
|
+
t.relatedmaterial(:path=>"archdesc/relatedmaterial/p")
|
53
|
+
t.relatedmaterial_heading(:path=>"archdesc/relatedmaterial/head", :index_as=>[:not_searchable, :displayable])
|
54
|
+
t.separatedmaterial(:path=>"archdesc/separatedmaterial/p")
|
55
|
+
t.separatedmaterial_heading(:path=>"archdesc/separatedmaterial/head", :index_as=>[:not_searchable, :displayable])
|
56
|
+
t.scopecontent(:path=>"archdesc/scopecontent/p")
|
57
|
+
t.scopecontent_heading(:path=>"archdesc/scopecontent/head", :index_as=>[:not_searchable, :displayable])
|
58
|
+
t.userestrict(:path=>"archdesc/userestrict/p")
|
59
|
+
t.userestrict_heading(:path=>"archdesc/userestrict/head", :index_as=>[:not_searchable, :displayable])
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def to_solr(solr_doc = Hash.new)
|
64
|
+
super(solr_doc)
|
65
|
+
solr_doc.merge!({"id" => self.eadid.first})
|
66
|
+
solr_doc.merge!({"eadid_s" => self.eadid.first})
|
67
|
+
solr_doc.merge!({"format" => "Archival Collection"})
|
68
|
+
solr_doc.merge!({"heading_display" => ("Guide to the " + self.title.first)})
|
69
|
+
return solr_doc
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|