hydra-pbcore 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +17 -0
- data/lib/hydra_pbcore/datastream/document.rb +1 -1
- data/lib/hydra_pbcore/mapper.rb +7 -1
- data/lib/hydra_pbcore/version.rb +1 -1
- data/spec/document_spec.rb +10 -2
- data/spec/fixtures/document.xml +4 -0
- data/spec/fixtures/document_solr.xml +12 -6
- metadata +8 -2
data/README.md
CHANGED
@@ -48,6 +48,23 @@ validate against the PBCore XML v.2 schema. Additionally, there are several tem
|
|
48
48
|
to insert additional terms into your xml documents, such as contributors, publishers, as well as next and previous
|
49
49
|
fields that specify which files come before and after one another in a multi-part born-digital video.
|
50
50
|
|
51
|
+
### Dates
|
52
|
+
|
53
|
+
Date fields in solr have to be in ISO8601 format, as opposed to text fields which may contain dates, but are treated differently.
|
54
|
+
The difference is with the former, solr is treating the value of the field as an actual date, and as such, it can do time-based
|
55
|
+
querying. The latter, is just a string and solr would search it accordingly. Currently, two types of date fields are provided:
|
56
|
+
"_dt" for single-valued date fields, and "_dts" for multi-valued date fields. Solr cannot sort on multi-valued date fields;
|
57
|
+
otherwise, the two functionally identical. By indexing your date fields as:
|
58
|
+
|
59
|
+
:index_as => [:displayable, :converted_date]
|
60
|
+
:index_as => [:displayable, :converted_multi_date]
|
61
|
+
|
62
|
+
the content of your date fields will be converted to ISO8601 dates, and the original content will be preserved for display.
|
63
|
+
So you could enter a date such as "2001" or "2004-10", and each will be stored for display as such, but will also be
|
64
|
+
indexed as a date in Solr with the value "2001-01-01T00:00:00Z" and "2004-10-01T00:00:00Z"
|
65
|
+
|
66
|
+
Note: these functions will likely change with the upgrade to Solrizer 3.0.
|
67
|
+
|
51
68
|
## Testing
|
52
69
|
|
53
70
|
To run all the rspec tests, use:
|
@@ -120,7 +120,7 @@ class Document < ActiveFedora::OmDatastream
|
|
120
120
|
)
|
121
121
|
t.event_date(:path=>"pbcoreCoverage/coverage",
|
122
122
|
:attributes => {:annotation=>"Event Date"},
|
123
|
-
:index_as => [:not_searchable, :
|
123
|
+
:index_as => [:not_searchable, :converted_multi_date, :displayable]
|
124
124
|
)
|
125
125
|
|
126
126
|
# Creator names and roles
|
data/lib/hydra_pbcore/mapper.rb
CHANGED
@@ -3,7 +3,8 @@ class HydraPbcore::Mapper < Solrizer::FieldMapper
|
|
3
3
|
id_field 'id'
|
4
4
|
index_as :searchable do |t|
|
5
5
|
t.default :suffix => '_t'
|
6
|
-
t.date :suffix => '_dt'
|
6
|
+
t.date :suffix => '_dt' # single-valued solr date fields
|
7
|
+
t.dates :suffix => '_dts' # multi-valued solr date fields
|
7
8
|
t.string :suffix => '_t'
|
8
9
|
t.text :suffix => '_t'
|
9
10
|
t.symbol :suffix => '_s'
|
@@ -22,6 +23,11 @@ class HydraPbcore::Mapper < Solrizer::FieldMapper
|
|
22
23
|
pbcore_date(value)
|
23
24
|
end
|
24
25
|
end
|
26
|
+
index_as :converted_multi_date do |t|
|
27
|
+
t.default :suffix => '_dts' do |value|
|
28
|
+
pbcore_date(value)
|
29
|
+
end
|
30
|
+
end
|
25
31
|
|
26
32
|
# We assume that all dates are in ISO 8601 format, but sometimes users may only
|
27
33
|
# specify a year or a year and month. This method adds a -01-01 or -01 respectively
|
data/lib/hydra_pbcore/version.rb
CHANGED
data/spec/document_spec.rb
CHANGED
@@ -127,6 +127,7 @@ describe HydraPbcore::Datastream::Document do
|
|
127
127
|
@object_ds.insert_contributor
|
128
128
|
@object_ds.insert_place("inserted")
|
129
129
|
@object_ds.insert_date("2012-11-11")
|
130
|
+
@object_ds.insert_date("2012-11-12")
|
130
131
|
|
131
132
|
@object_ds.insert_relation("inserted", 'Archival Collection')
|
132
133
|
@object_ds.insert_relation("inserted", 'Event Series')
|
@@ -169,11 +170,11 @@ describe HydraPbcore::Datastream::Document do
|
|
169
170
|
|
170
171
|
describe "solr dates" do
|
171
172
|
it "should be indexed for display" do
|
172
|
-
@object_ds.to_solr["event_date_display"].should == ["2012-11-11"]
|
173
|
+
@object_ds.to_solr["event_date_display"].should == ["2012-11-11", "2012-11-12"]
|
173
174
|
end
|
174
175
|
|
175
176
|
it "should be converted to ISO 8601" do
|
176
|
-
@object_ds.to_solr["
|
177
|
+
@object_ds.to_solr["event_date_dts"].should == ["2012-11-11T00:00:00Z", "2012-11-12T00:00:00Z"]
|
177
178
|
end
|
178
179
|
|
179
180
|
it "should not be searchable as strings" do
|
@@ -223,6 +224,13 @@ describe HydraPbcore::Datastream::Document do
|
|
223
224
|
ds.to_solr["creator_name_facet"].should == ["foo"]
|
224
225
|
end
|
225
226
|
|
227
|
+
it "should accept partial dates" do
|
228
|
+
ds = HydraPbcore::Datastream::Document.new(nil, nil)
|
229
|
+
ds.insert_date("2001")
|
230
|
+
ds.insert_date("2004-10")
|
231
|
+
ds.to_solr["event_date_dts"].should == ["2001-01-01T00:00:00Z", "2004-10-01T00:00:00Z"]
|
232
|
+
end
|
233
|
+
|
226
234
|
end
|
227
235
|
|
228
236
|
end
|
data/spec/fixtures/document.xml
CHANGED
@@ -35,6 +35,10 @@
|
|
35
35
|
<coverage annotation="Event Date">2012-11-11</coverage>
|
36
36
|
<coverageType>Temporal</coverageType>
|
37
37
|
</pbcoreCoverage>
|
38
|
+
<pbcoreCoverage>
|
39
|
+
<coverage annotation="Event Date">2012-11-12</coverage>
|
40
|
+
<coverageType>Temporal</coverageType>
|
41
|
+
</pbcoreCoverage>
|
38
42
|
<pbcoreRelation>
|
39
43
|
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
40
44
|
<pbcoreRelationIdentifier annotation="Archival Collection">inserted</pbcoreRelationIdentifier>
|
@@ -212,17 +212,21 @@
|
|
212
212
|
<pbcoreDescriptionDocument-0-event-place-display type="array">
|
213
213
|
<pbcoreDescriptionDocument-0-event-place-display>inserted</pbcoreDescriptionDocument-0-event-place-display>
|
214
214
|
</pbcoreDescriptionDocument-0-event-place-display>
|
215
|
-
<pbcoreDescriptionDocument-event-date-
|
215
|
+
<pbcoreDescriptionDocument-event-date-dts type="array">
|
216
216
|
<pbcoreDescriptionDocument-event-date-dt>2012-11-11T00:00:00Z</pbcoreDescriptionDocument-event-date-dt>
|
217
|
-
|
217
|
+
<pbcoreDescriptionDocument-event-date-dt>2012-11-12T00:00:00Z</pbcoreDescriptionDocument-event-date-dt>
|
218
|
+
</pbcoreDescriptionDocument-event-date-dts>
|
218
219
|
<pbcoreDescriptionDocument-event-date-display type="array">
|
219
220
|
<pbcoreDescriptionDocument-event-date-display>2012-11-11</pbcoreDescriptionDocument-event-date-display>
|
221
|
+
<pbcoreDescriptionDocument-event-date-display>2012-11-12</pbcoreDescriptionDocument-event-date-display>
|
220
222
|
</pbcoreDescriptionDocument-event-date-display>
|
221
|
-
<pbcoreDescriptionDocument-0-event-date-
|
223
|
+
<pbcoreDescriptionDocument-0-event-date-dts type="array">
|
222
224
|
<pbcoreDescriptionDocument-0-event-date-dt>2012-11-11T00:00:00Z</pbcoreDescriptionDocument-0-event-date-dt>
|
223
|
-
|
225
|
+
<pbcoreDescriptionDocument-0-event-date-dt>2012-11-12T00:00:00Z</pbcoreDescriptionDocument-0-event-date-dt>
|
226
|
+
</pbcoreDescriptionDocument-0-event-date-dts>
|
224
227
|
<pbcoreDescriptionDocument-0-event-date-display type="array">
|
225
228
|
<pbcoreDescriptionDocument-0-event-date-display>2012-11-11</pbcoreDescriptionDocument-0-event-date-display>
|
229
|
+
<pbcoreDescriptionDocument-0-event-date-display>2012-11-12</pbcoreDescriptionDocument-0-event-date-display>
|
226
230
|
</pbcoreDescriptionDocument-0-event-date-display>
|
227
231
|
<pbcoreDescriptionDocument-note-t type="array">
|
228
232
|
<pbcoreDescriptionDocument-note-t>inserted</pbcoreDescriptionDocument-note-t>
|
@@ -378,11 +382,13 @@
|
|
378
382
|
<event-place-display type="array">
|
379
383
|
<event-place-display>inserted</event-place-display>
|
380
384
|
</event-place-display>
|
381
|
-
<event-date-
|
385
|
+
<event-date-dts type="array">
|
382
386
|
<event-date-dt>2012-11-11T00:00:00Z</event-date-dt>
|
383
|
-
|
387
|
+
<event-date-dt>2012-11-12T00:00:00Z</event-date-dt>
|
388
|
+
</event-date-dts>
|
384
389
|
<event-date-display type="array">
|
385
390
|
<event-date-display>2012-11-11</event-date-display>
|
391
|
+
<event-date-display>2012-11-12</event-date-display>
|
386
392
|
</event-date-display>
|
387
393
|
<contributor-name-t type="array">
|
388
394
|
<contributor-name-t>inserted</contributor-name-t>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-pbcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active-fedora
|
@@ -217,12 +217,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- - ! '>='
|
218
218
|
- !ruby/object:Gem::Version
|
219
219
|
version: '0'
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
hash: 3539419655098167212
|
220
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
224
|
none: false
|
222
225
|
requirements:
|
223
226
|
- - ! '>='
|
224
227
|
- !ruby/object:Gem::Version
|
225
228
|
version: '0'
|
229
|
+
segments:
|
230
|
+
- 0
|
231
|
+
hash: 3539419655098167212
|
226
232
|
requirements: []
|
227
233
|
rubyforge_project:
|
228
234
|
rubygems_version: 1.8.23
|