solr_ead 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/solr_ead/behaviors.rb +9 -7
- data/lib/solr_ead/component.rb +0 -28
- data/lib/solr_ead/document.rb +9 -22
- data/lib/solr_ead/version.rb +1 -1
- data/spec/component_spec.rb +5 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDQzY2IzYzhhODUxZTg0NTk0Njk1YzczN2U2ZWY1NGM0OTVhNTAwOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzIyMzM2N2U3MDkwMjJjNDc0MmZkZTJjNzJhZmFmY2FhMWQzNjRmYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWMwYTZiYjdlNzY0YjU0YWUwN2FhYjljYzEwOTcyOGExYTVlMjY5MmUzODlh
|
10
|
+
NjFlMzAxZWIwNDkwNzYyYzJkOGYxMDJmZjA1MWRjZGZlYzE5ZTQ2NzQyODFh
|
11
|
+
Mzc5MDAwNTJmYjljMzM0ZDQ0YWUzMGQ2ZmIyYzJhNTk2MGMwMDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmQzNjA0NzdjYzA5MDkyMTI3MGNkMjFlZDEyMDQzZTVhYmFjMTc0NDc3ODk4
|
14
|
+
NjQwMmEyZjUzMTVhZDZhMzZlMmQ3ZjY0ZThjNmUxMDgxMjMxMjRhZTQ1YmIy
|
15
|
+
YjNlOGExYjM3ZTEyNDdhYmI4ODUwMjgxMDllOTcxNTFkOGIxNDk=
|
data/lib/solr_ead/behaviors.rb
CHANGED
@@ -47,13 +47,14 @@ module SolrEad::Behaviors
|
|
47
47
|
# The solr fields returned by this method are:
|
48
48
|
#
|
49
49
|
# id:: Unique identifier using the id attribute and the <eadid>
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
50
|
+
# ead_ssi:: The <eadid> node of the ead. This is so we know which ead this component belongs to.
|
51
|
+
# parent_ssi:: The id attribute of the parent <c> node
|
52
|
+
# parent_ssm:: Array of all the parent component ids for a given component.
|
53
|
+
# parent_unittitles_ssm:: Array of title fields for all the parent components of a given component.
|
54
|
+
# parent_unittitles_teim:: Same as above but indexed
|
55
|
+
# component_level_ii:: numeric level of the component
|
56
|
+
# component_children_bsi:: Boolean field indicating whether or not the component has any child <c> nodes attached to it
|
57
|
+
# collection_sim:: Title field of the ead document so we can facet on all components in a collection
|
57
58
|
#
|
58
59
|
# These fields are used so that we may reconstruct placement of a single component
|
59
60
|
# within the hierarchy of the original ead.
|
@@ -63,6 +64,7 @@ module SolrEad::Behaviors
|
|
63
64
|
addl_fields[Solrizer.solr_name("parent", :stored_sortable)] = node.parent.attr("id") unless node.parent.attr("id").nil?
|
64
65
|
addl_fields[Solrizer.solr_name("parent", :displayable)] = parent_id_list(node)
|
65
66
|
addl_fields[Solrizer.solr_name("parent_unittitles", :displayable)] = parent_unittitle_list(node)
|
67
|
+
addl_fields[Solrizer.solr_name("parent_unittitles", :searchable)] = parent_unittitle_list(node)
|
66
68
|
addl_fields[Solrizer.solr_name("component_level", :type => :integer)] = parent_id_list(node).length + 1
|
67
69
|
addl_fields[Solrizer.solr_name("component_children", :type => :boolean)] = component_children?(node)
|
68
70
|
addl_fields[Solrizer.solr_name("collection", :facetable)] = node.xpath("//archdesc/did/unittitle").text
|
data/lib/solr_ead/component.rb
CHANGED
@@ -8,7 +8,6 @@ class SolrEad::Component
|
|
8
8
|
t.root(:path=>"c")
|
9
9
|
t.ref_(:path=>"/c/@id")
|
10
10
|
t.level(:path=>"/c/@level", :index_as=>[:facetable])
|
11
|
-
|
12
11
|
t.title(:path=>"unittitle", :attributes=>{ :type => :none }, :index_as=>[:displayable])
|
13
12
|
t.unitdate(:index_as=>[:displayable])
|
14
13
|
|
@@ -21,12 +20,6 @@ class SolrEad::Component
|
|
21
20
|
t.persname(:index_as=>[:facetable])
|
22
21
|
t.subject(:index_as=>[:facetable])
|
23
22
|
|
24
|
-
# These terms are proxied to match with Blacklight's default facets, but otherwise
|
25
|
-
# you can remove them or rename the above facet terms to match with your solr
|
26
|
-
# implementation.
|
27
|
-
t.subject_geo(:proxy=>[:geogname])
|
28
|
-
t.subject_topic(:proxy=>[:subject])
|
29
|
-
|
30
23
|
# Item
|
31
24
|
t.container {
|
32
25
|
t.label(:path => {:attribute=>"label"})
|
@@ -73,32 +66,11 @@ class SolrEad::Component
|
|
73
66
|
t.scopecontent_heading(:path=>"scopecontent/head")
|
74
67
|
t.userestrict(:path=>"userestrict/p", :index_as=>[:displayable])
|
75
68
|
t.userestrict_heading(:path=>"userestrict/head")
|
76
|
-
|
77
|
-
# <odd> nodes
|
78
|
-
# These guys depend on what's in <head> so we do some xpathy stuff...
|
79
|
-
t.note(:path=>'odd[./head="General note"]/p', :index_as=>[:displayable])
|
80
|
-
t.accession(:path=>'odd[./head[starts-with(.,"Museum Accession")]]/p', :index_as=>[:displayable])
|
81
|
-
t.print_run(:path=>'odd[./head[starts-with(.,"Limited")]]/p', :index_as=>[:displayable])
|
82
|
-
|
83
69
|
end
|
84
70
|
|
85
71
|
def to_solr(solr_doc = Hash.new)
|
86
72
|
super(solr_doc)
|
87
|
-
Solrizer.insert_field(solr_doc, "format", "Archival Item", :facetable)
|
88
|
-
heading = get_heading solr_doc[Solrizer.solr_name("parent_unittitles", :displayable)]
|
89
|
-
Solrizer.insert_field(solr_doc, "heading", heading, :displayable) unless heading.nil?
|
90
73
|
Solrizer.insert_field(solr_doc, "ref", self.ref.first.strip, :stored_sortable)
|
91
74
|
end
|
92
75
|
|
93
|
-
protected
|
94
|
-
|
95
|
-
def get_heading parent_titles = Array.new
|
96
|
-
return nil if parent_titles.nil?
|
97
|
-
if parent_titles.length > 0
|
98
|
-
[parent_titles, self.title.first].join(" >> ")
|
99
|
-
else
|
100
|
-
self.title.first
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
76
|
end
|
data/lib/solr_ead/document.rb
CHANGED
@@ -7,22 +7,7 @@ class SolrEad::Document
|
|
7
7
|
# Define each term in your ead that you want put into the solr document
|
8
8
|
set_terminology do |t|
|
9
9
|
t.root(:path=>"ead")
|
10
|
-
|
11
10
|
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
11
|
t.title(:path=>"archdesc/did/unittitle", :index_as=>[:searchable, :displayable])
|
27
12
|
t.title_filing(:path=>"titleproper", :attributes=>{ :type => "filing" }, :index_as=>[:sortable])
|
28
13
|
t.title_num(:path=>"archdesc/did/unitid")
|
@@ -34,9 +19,16 @@ class SolrEad::Document
|
|
34
19
|
t.langcode(:path=>"did/langmaterial/language/@langcode")
|
35
20
|
t.abstract(:path=>"archdesc/did/abstract", :index_as=>[:searchable])
|
36
21
|
|
22
|
+
# Facets
|
23
|
+
t.corpname(:index_as=>[:facetable])
|
24
|
+
t.famname(:index_as=>[:facetable])
|
25
|
+
t.genreform(:index_as=>[:facetable])
|
26
|
+
t.geogname(:index_as=>[:facetable])
|
27
|
+
t.name(:index_as=>[:facetable])
|
28
|
+
t.persname(:index_as=>[:facetable])
|
29
|
+
t.subject(:index_as=>[:facetable])
|
37
30
|
t.collection(:proxy=>[:title], :index_as=>[:facetable])
|
38
31
|
|
39
|
-
|
40
32
|
# General field available within archdesc
|
41
33
|
t.accessrestrict(:path=>"archdesc/accessrestrict/p", :index_as=>[:searchable])
|
42
34
|
t.accessrestrict_heading(:path=>"archdesc/accessrestrict/head", :index_as=>[:displayable])
|
@@ -77,13 +69,8 @@ class SolrEad::Document
|
|
77
69
|
|
78
70
|
def to_solr(solr_doc = Hash.new)
|
79
71
|
super(solr_doc)
|
80
|
-
solr_doc.merge!({"id"
|
81
|
-
Solrizer.insert_field(solr_doc, "format", "Archival Collection", :facetable)
|
72
|
+
solr_doc.merge!({"id" => self.eadid.first.strip})
|
82
73
|
Solrizer.insert_field(solr_doc, "ead", self.eadid.first.strip, :stored_sortable)
|
83
|
-
unless self.title_num.empty?
|
84
|
-
heading = "Guide to the " + self.title.first + " (" + self.title_num.first + ")"
|
85
|
-
Solrizer.insert_field(solr_doc, "heading", heading, :displayable)
|
86
|
-
end
|
87
74
|
return solr_doc
|
88
75
|
end
|
89
76
|
|
data/lib/solr_ead/version.rb
CHANGED
data/spec/component_spec.rb
CHANGED
@@ -14,8 +14,8 @@ describe SolrEad::Component do
|
|
14
14
|
before :each do
|
15
15
|
additional_fields = {
|
16
16
|
"id" => "TEST-0001ref010",
|
17
|
-
Solrizer.solr_name("ead", :stored_sortable)
|
18
|
-
Solrizer.solr_name("parent", :stored_sortable)
|
17
|
+
Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
|
18
|
+
Solrizer.solr_name("parent", :stored_sortable) => "ref001",
|
19
19
|
Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
|
20
20
|
Solrizer.solr_name("parent_unittitles", :displayable) => ["Series I", "Subseries A", "Subseries 1"],
|
21
21
|
Solrizer.solr_name("component_children", :type => :boolean) => FALSE
|
@@ -26,7 +26,6 @@ describe SolrEad::Component do
|
|
26
26
|
it "should accept additional fields from a hash" do
|
27
27
|
@solr_doc["id"].should == "TEST-0001ref010"
|
28
28
|
@solr_doc[Solrizer.solr_name("level", :facetable)].should include "item"
|
29
|
-
@solr_doc[Solrizer.solr_name("heading", :displayable)].first.should == "Series I >> Subseries A >> Subseries 1 >> Internal Revenue Service Form Information Return [RESTRICTED]"
|
30
29
|
@solr_doc[Solrizer.solr_name("accessrestrict", :displayable)].first.should match /^This item .* is available.$/
|
31
30
|
end
|
32
31
|
|
@@ -38,9 +37,9 @@ describe SolrEad::Component do
|
|
38
37
|
|
39
38
|
it "should format heading_display with only one element" do
|
40
39
|
additional_fields = {
|
41
|
-
"id"
|
42
|
-
Solrizer.solr_name("ead", :stored_sortable)
|
43
|
-
Solrizer.solr_name("parent", :stored_sortable)
|
40
|
+
"id" => "TEST-0001ref010",
|
41
|
+
Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
|
42
|
+
Solrizer.solr_name("parent", :stored_sortable) => "ref001",
|
44
43
|
Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
|
45
44
|
Solrizer.solr_name("parent_unittitles", :displayable) => [],
|
46
45
|
Solrizer.solr_name("component_children", :type => :boolean) => FALSE
|
@@ -48,7 +47,6 @@ describe SolrEad::Component do
|
|
48
47
|
solr_doc = @doc.to_solr(additional_fields)
|
49
48
|
solr_doc["id"].should == "TEST-0001ref010"
|
50
49
|
solr_doc[Solrizer.solr_name("level", :facetable)].should include "item"
|
51
|
-
solr_doc[Solrizer.solr_name("heading", :displayable)].first.should == "Internal Revenue Service Form Information Return [RESTRICTED]"
|
52
50
|
solr_doc[Solrizer.solr_name("accessrestrict", :displayable)].first.should match /^This item .* is available.$/
|
53
51
|
end
|
54
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solr_ead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Wead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: om
|