solrizer 2.2.0 → 3.0.0.pre1
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/.gitignore +1 -1
- data/History.txt +12 -0
- data/lib/solrizer/common.rb +3 -18
- data/lib/solrizer/default_descriptors.rb +93 -0
- data/lib/solrizer/descriptor.rb +68 -0
- data/lib/solrizer/field_mapper.rb +107 -288
- data/lib/solrizer/version.rb +1 -1
- data/lib/solrizer/xml/extractor.rb +5 -5
- data/lib/solrizer/xml/terminology_based_solrizer.rb +4 -20
- data/lib/solrizer.rb +1 -1
- data/solrizer.gemspec +1 -1
- data/spec/fixtures/mods_article.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/units/common_spec.rb +8 -12
- data/spec/units/extractor_spec.rb +3 -2
- data/spec/units/field_mapper_spec.rb +177 -141
- data/spec/units/xml_extractor_spec.rb +13 -14
- data/spec/units/xml_terminology_based_solrizer_spec.rb +13 -22
- metadata +56 -33
- checksums.yaml +0 -7
- data/lib/solrizer/field_name_mapper.rb +0 -51
- data/spec/units/field_name_mapper_spec.rb +0 -28
@@ -3,39 +3,127 @@ require 'spec_helper'
|
|
3
3
|
describe Solrizer::FieldMapper do
|
4
4
|
|
5
5
|
# --- Test Mappings ----
|
6
|
-
|
7
6
|
class TestMapper0 < Solrizer::FieldMapper
|
8
|
-
id_field 'ident'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
"How many #{field_name}s does it take to screw in a light bulb? #{value.capitalize}."
|
7
|
+
self.id_field= 'ident'
|
8
|
+
module Descriptors0
|
9
|
+
# Produces a _s suffix (overrides _tim)
|
10
|
+
def self.unstemmed_searchable
|
11
|
+
@unstemmed_searchable ||= UnstemmedDescriptor.new()
|
14
12
|
end
|
15
|
-
|
16
|
-
|
13
|
+
|
14
|
+
# Produces a _s suffix (overrides _tim)
|
15
|
+
def self.searchable
|
16
|
+
@searchable ||= SearchableDescriptor.new()
|
17
17
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
|
19
|
+
# Produces a _s suffix (overrides _tim)
|
20
|
+
def self.another_searchable
|
21
|
+
@another_searchable ||= SearchableDescriptor.new()
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.edible
|
25
|
+
@edible ||= EdibleDescriptor.new()
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.fungible
|
29
|
+
@fungible ||= FungibleDescriptor.new()
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.laughable
|
33
|
+
@laughable ||= LaughableDescriptor.new()
|
34
|
+
end
|
35
|
+
|
36
|
+
class UnstemmedDescriptor < Solrizer::Descriptor
|
37
|
+
def name_and_converter(field_name, args)
|
38
|
+
[field_name + '_s', lambda { |value| "#{value} o'clock" }]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class SearchableDescriptor < Solrizer::Descriptor
|
43
|
+
def name_and_converter(field_name, args)
|
44
|
+
[field_name.to_s + '_s']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class EdibleDescriptor < Solrizer::Descriptor
|
49
|
+
def name_and_converter(field_name, args)
|
50
|
+
[field_name + '_food']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class FungibleDescriptor < Solrizer::Descriptor
|
55
|
+
def name_and_converter(field_name, args)
|
56
|
+
[field_name + fungible_type(args[:type])]
|
57
|
+
end
|
58
|
+
def fungible_type(type)
|
59
|
+
case type
|
60
|
+
when :integer
|
61
|
+
'_f1'
|
62
|
+
when :date
|
63
|
+
'_f0'
|
64
|
+
else
|
65
|
+
'_f2'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class LaughableDescriptor < Solrizer::Descriptor
|
71
|
+
def name_and_converter(field_name, args)
|
72
|
+
field_type = args[:type]
|
73
|
+
[field_name + laughable_type(field_type), laughable_converter(field_type)]
|
74
|
+
end
|
75
|
+
|
76
|
+
def laughable_type(type)
|
77
|
+
case type
|
78
|
+
when :integer
|
79
|
+
'_ihaha'
|
80
|
+
else
|
81
|
+
'_haha'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def laughable_converter(type)
|
86
|
+
case type
|
87
|
+
when :integer
|
88
|
+
lambda do |value, field_name|
|
89
|
+
"How many #{field_name}s does it take to screw in a light bulb? #{value}."
|
90
|
+
end
|
91
|
+
else
|
92
|
+
lambda do |value|
|
93
|
+
"Knock knock. Who's there? #{value.capitalize}. #{value.capitalize} who?"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
27
97
|
end
|
28
98
|
end
|
99
|
+
|
100
|
+
self.descriptors = [Descriptors0, Solrizer::DefaultDescriptors]
|
29
101
|
end
|
30
102
|
|
31
103
|
class TestMapper1 < TestMapper0
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
104
|
+
module Descriptors1
|
105
|
+
def self.fungible
|
106
|
+
@fungible ||= FungibleDescriptor.new()
|
107
|
+
end
|
108
|
+
|
109
|
+
class FungibleDescriptor < TestMapper0::Descriptors0::FungibleDescriptor
|
110
|
+
def name_and_converter(field_name, args)
|
111
|
+
[field_name + fungible_type(args[:type])]
|
112
|
+
end
|
113
|
+
|
114
|
+
def fungible_type(type)
|
115
|
+
case type
|
116
|
+
when :garble
|
117
|
+
'_f4'
|
118
|
+
when :integer
|
119
|
+
'_f5'
|
120
|
+
else
|
121
|
+
super
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
38
125
|
end
|
126
|
+
self.descriptors = [Descriptors1, Descriptors0, Solrizer::DefaultDescriptors]
|
39
127
|
end
|
40
128
|
|
41
129
|
before(:each) do
|
@@ -50,185 +138,133 @@ describe Solrizer::FieldMapper do
|
|
50
138
|
it "should handle the id field" do
|
51
139
|
@mapper.id_field.should == 'ident'
|
52
140
|
end
|
141
|
+
|
142
|
+
|
143
|
+
describe "extract_type" do
|
144
|
+
it "should map objects to symbols" do
|
145
|
+
@mapper.extract_type(7).should == :integer
|
146
|
+
@mapper.extract_type(nil).should == nil
|
147
|
+
@mapper.extract_type(Date.today).should == :date
|
148
|
+
@mapper.extract_type("Hi").should == :string
|
149
|
+
end
|
150
|
+
end
|
53
151
|
|
54
152
|
describe '.solr_name' do
|
55
153
|
it "should map based on index_as" do
|
56
|
-
@mapper.solr_name('bar', :
|
57
|
-
@mapper.solr_name('bar', :
|
154
|
+
@mapper.solr_name('bar', :edible).should == 'bar_food'
|
155
|
+
@mapper.solr_name('bar', :laughable, type: :string).should == 'bar_haha'
|
58
156
|
end
|
59
157
|
|
60
158
|
it "should default the index_type to :searchable" do
|
61
|
-
@mapper.solr_name('foo'
|
159
|
+
@mapper.solr_name('foo').should == 'foo_s'
|
62
160
|
end
|
63
|
-
|
161
|
+
|
64
162
|
it "should map based on data type" do
|
65
|
-
@mapper.solr_name('foo', :
|
66
|
-
@mapper.solr_name('foo', :
|
67
|
-
@mapper.solr_name('foo', :
|
163
|
+
@mapper.solr_name('foo', :fungible, type: :integer).should == 'foo_f1'
|
164
|
+
@mapper.solr_name('foo', :fungible, type: :garble).should == 'foo_f2' # based on type.default
|
165
|
+
@mapper.solr_name('foo', :fungible, type: :date).should == 'foo_f0' # type.date falls through to container
|
68
166
|
end
|
69
167
|
|
70
168
|
it "should return nil for an unknown index types" do
|
71
|
-
|
72
|
-
@mapper.solr_name('foo', :
|
73
|
-
|
169
|
+
lambda {
|
170
|
+
@mapper.solr_name('foo', :blargle)
|
171
|
+
}.should raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
|
74
172
|
end
|
75
173
|
|
76
174
|
it "should allow subclasses to selectively override suffixes" do
|
77
175
|
@mapper = TestMapper1.new
|
78
|
-
@mapper.solr_name('foo', :date).should == '
|
79
|
-
@mapper.solr_name('foo', :string).should == 'foo_s'
|
80
|
-
@mapper.solr_name('foo', :
|
81
|
-
@mapper.solr_name('foo', :
|
82
|
-
@mapper.solr_name('foo', :
|
83
|
-
@mapper.solr_name('foo', :
|
176
|
+
@mapper.solr_name('foo', type: :date).should == 'foo_s'
|
177
|
+
@mapper.solr_name('foo', type: :string).should == 'foo_s'
|
178
|
+
@mapper.solr_name('foo', :fungible, type: :integer).should == 'foo_f5' # override on data type
|
179
|
+
@mapper.solr_name('foo', :fungible, type: :garble).should == 'foo_f4' # override on data type
|
180
|
+
@mapper.solr_name('foo', :fungible, type: :fratz).should == 'foo_f2' # from super
|
181
|
+
@mapper.solr_name('foo', :fungible, type: :date).should == 'foo_f0' # super definition picks up override on index type
|
84
182
|
end
|
85
183
|
|
86
|
-
it "should support field names as symbols" do
|
87
|
-
@mapper.solr_name(:active_fedora_model, :symbol).should == "active_fedora_model_s"
|
88
|
-
end
|
89
184
|
|
90
|
-
it "should
|
91
|
-
mapper = Solrizer::FieldMapper
|
92
|
-
mapper.solr_name(:heifer, nil, :searchable).should
|
185
|
+
it "should raise an error when field_type is nil" do
|
186
|
+
mapper = Solrizer::FieldMapper.new
|
187
|
+
lambda { mapper.solr_name(:heifer, nil, :searchable)}.should raise_error Solrizer::InvalidIndexDescriptor
|
93
188
|
end
|
94
189
|
end
|
95
190
|
|
96
191
|
describe '.solr_names_and_values' do
|
97
192
|
it "should map values based on index_as" do
|
98
|
-
@mapper.solr_names_and_values('foo', 'bar',
|
193
|
+
@mapper.solr_names_and_values('foo', 'bar', [:searchable, :laughable, :edible]).should == {
|
99
194
|
'foo_s' => ['bar'],
|
100
195
|
'foo_food' => ['bar'],
|
101
196
|
'foo_haha' => ["Knock knock. Who's there? Bar. Bar who?"]
|
102
197
|
}
|
103
198
|
end
|
104
199
|
|
105
|
-
it "should apply default index_as mapping unless excluded with not_" do
|
106
|
-
@mapper.solr_names_and_values('foo', 'bar', :string, []).should == {
|
107
|
-
'foo_s' => ['bar'],
|
108
|
-
'foo_haha' => ["Knock knock. Who's there? Bar. Bar who?"]
|
109
|
-
}
|
110
|
-
@mapper.solr_names_and_values('foo', 'bar', :string, [:edible, :not_laughable]).should == {
|
111
|
-
'foo_s' => ['bar'],
|
112
|
-
'foo_food' => ['bar']
|
113
|
-
}
|
114
|
-
@mapper.solr_names_and_values('foo', 'bar', :string, [:not_searchable, :not_laughable]).should == {}
|
115
|
-
end
|
116
|
-
|
117
200
|
it "should apply mappings based on data type" do
|
118
|
-
@mapper.solr_names_and_values('foo',
|
119
|
-
'foo_s' => ['
|
120
|
-
'foo_ihaha' => ["How many foos does it take to screw in a light bulb?
|
201
|
+
@mapper.solr_names_and_values('foo', 7, [:searchable, :laughable]).should == {
|
202
|
+
'foo_s' => ['7'],
|
203
|
+
'foo_ihaha' => ["How many foos does it take to screw in a light bulb? 7."]
|
121
204
|
}
|
122
205
|
end
|
123
206
|
|
124
|
-
it "should
|
125
|
-
|
126
|
-
@mapper.solr_names_and_values('foo', 'bar',
|
127
|
-
|
128
|
-
'foo_haha' => ["Knock knock. Who's there? Bar. Bar who?"]
|
129
|
-
}
|
130
|
-
end
|
207
|
+
it "should raise error on unknown index types" do
|
208
|
+
lambda {
|
209
|
+
@mapper.solr_names_and_values('foo', 'bar', [:blargle])
|
210
|
+
}.should raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
|
131
211
|
end
|
132
212
|
|
133
213
|
it "should generate multiple mappings when two return the _same_ solr name but _different_ values" do
|
134
|
-
@mapper.solr_names_and_values('roll', 'rock',
|
214
|
+
@mapper.solr_names_and_values('roll', 'rock', [:unstemmed_searchable, :searchable]).should == {
|
135
215
|
'roll_s' => ["rock o'clock", 'rock']
|
136
216
|
}
|
137
217
|
end
|
138
218
|
|
139
219
|
it "should not generate multiple mappings when two return the _same_ solr name and the _same_ value" do
|
140
|
-
@mapper.solr_names_and_values('roll', 'rock',
|
220
|
+
@mapper.solr_names_and_values('roll', 'rock', [:another_searchable, :searchable]).should == {
|
141
221
|
'roll_s' => ['rock'],
|
142
222
|
}
|
143
223
|
end
|
144
|
-
end
|
145
224
|
|
146
|
-
|
147
|
-
|
148
|
-
class TestMapperLoading < Solrizer::FieldMapper
|
149
|
-
end
|
225
|
+
it "should return an empty hash when value is nil" do
|
226
|
+
@mapper.solr_names_and_values('roll', nil, [:another_searchable, :searchable]).should == { }
|
150
227
|
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
mapper = TestMapperLoading.new
|
155
|
-
mappings_from_file = YAML::load(File.open(file_path))
|
156
|
-
mapper.id_field.should == "pid"
|
157
|
-
mapper.mappings[:edible].opts[:default].should == true
|
158
|
-
mapper.mappings[:edible].data_types[:boolean].opts[:suffix].should == "_edible_bool"
|
159
|
-
mappings_from_file["edible"].each_pair do |k,v|
|
160
|
-
mapper.mappings[:edible].data_types[k.to_sym].opts[:suffix].should == v
|
161
|
-
end
|
162
|
-
mapper.mappings[:displayable].opts[:suffix].should == mappings_from_file["displayable"]
|
163
|
-
mapper.mappings[:facetable].opts[:suffix].should == mappings_from_file["facetable"]
|
164
|
-
mapper.mappings[:sortable].opts[:suffix].should == mappings_from_file["sortable"]
|
165
|
-
end
|
166
|
-
it 'should default to using the mappings from config/solr_mappings.yml' do
|
167
|
-
TestMapperLoading.load_mappings
|
168
|
-
mapper = TestMapperLoading.new
|
169
|
-
default_file_path = File.join(File.dirname(__FILE__), "..", "..","config","solr_mappings.yml")
|
170
|
-
mappings_from_file = YAML::load(File.open(default_file_path))
|
171
|
-
mapper.id_field.should == mappings_from_file["id"]
|
172
|
-
mappings_from_file["searchable"].each_pair do |k,v|
|
173
|
-
mapper.mappings[:searchable].data_types[k.to_sym].opts[:suffix].should == v
|
174
|
-
end
|
175
|
-
mapper.mappings[:displayable].opts[:suffix].should == mappings_from_file["displayable"]
|
176
|
-
mapper.mappings[:facetable].opts[:suffix].should == mappings_from_file["facetable"]
|
177
|
-
mapper.mappings[:sortable].opts[:suffix].should == mappings_from_file["sortable"]
|
178
|
-
end
|
179
|
-
it "should wipe out pre-existing mappings without affecting other FieldMappers" do
|
180
|
-
TestMapperLoading.load_mappings
|
181
|
-
file_path = File.join(File.dirname(__FILE__), "..", "fixtures","test_solr_mappings.yml")
|
182
|
-
TestMapperLoading.load_mappings(file_path)
|
183
|
-
mapper = TestMapperLoading.new
|
184
|
-
mapper.mappings[:searchable].should be_nil
|
185
|
-
default_mapper = Solrizer::FieldMapper::Default.new
|
186
|
-
default_mapper.mappings[:searchable].should_not be_nil
|
187
|
-
end
|
188
|
-
it "should raise an informative error if the yaml file is structured improperly"
|
189
|
-
it "should raise an informative error if there is no YAML file"
|
190
|
-
end
|
191
|
-
|
192
|
-
describe Solrizer::FieldMapper::Default do
|
228
|
+
end
|
229
|
+
|
230
|
+
describe Solrizer::FieldMapper do
|
193
231
|
before(:each) do
|
194
|
-
@mapper = Solrizer::FieldMapper
|
232
|
+
@mapper = Solrizer::FieldMapper.new
|
195
233
|
end
|
196
234
|
|
197
235
|
it "should call the id field 'id'" do
|
198
236
|
@mapper.id_field.should == 'id'
|
199
237
|
end
|
238
|
+
|
239
|
+
it "should default the index_type to :searchable" do
|
240
|
+
@mapper.solr_name('foo', :type=>:string).should == 'foo_tesim'
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should support field names as symbols" do
|
244
|
+
@mapper.solr_name(:active_fedora_model, :symbol).should == "active_fedora_model_ssim"
|
245
|
+
end
|
200
246
|
|
201
247
|
it "should not apply mappings for searchable by default" do
|
202
248
|
# Just sanity check a couple; copy & pasting all data types is silly
|
203
|
-
@mapper.solr_names_and_values('foo', 'bar',
|
204
|
-
@mapper.solr_names_and_values('foo', "1",
|
249
|
+
@mapper.solr_names_and_values('foo', 'bar', []).should == { }
|
250
|
+
@mapper.solr_names_and_values('foo', "1",[]).should == { }
|
205
251
|
end
|
206
252
|
|
207
253
|
it "should support full ISO 8601 dates" do
|
208
|
-
@mapper.solr_names_and_values('foo', "2012-11-06",
|
209
|
-
@mapper.solr_names_and_values('foo', "November 6th, 2012",
|
210
|
-
@mapper.solr_names_and_values('foo',
|
211
|
-
@mapper.solr_names_and_values('foo', '',
|
254
|
+
@mapper.solr_names_and_values('foo', "2012-11-06", [:dateable]).should == { 'foo_dtsi' =>["2012-11-06T00:00:00Z"] }
|
255
|
+
@mapper.solr_names_and_values('foo', "November 6th, 2012", [:dateable]).should == { 'foo_dtsi' =>["2012-11-06T00:00:00Z"] }
|
256
|
+
@mapper.solr_names_and_values('foo', "6 Nov. 2012", [:dateable]).should == { 'foo_dtsi' =>["2012-11-06T00:00:00Z"] }
|
257
|
+
@mapper.solr_names_and_values('foo', '', [:dateable]).should == { 'foo_dtsi' => [] }
|
212
258
|
end
|
213
259
|
|
214
260
|
it "should support displayable, facetable, sortable, unstemmed" do
|
215
|
-
@mapper.solr_names_and_values('foo', 'bar',
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
261
|
+
@mapper.solr_names_and_values('foo', 'bar', [:searchable, :displayable, :facetable, :sortable, :unstemmed_searchable]).should == {
|
262
|
+
"foo_tesim" => ["bar"], #searchable
|
263
|
+
"foo_sim" => ["bar"], #facetable
|
264
|
+
"foo_ssm" => ["bar"], #displayable
|
265
|
+
"foo_ssi" => ["bar"], #sortable
|
266
|
+
"foo_tim" => ["bar"] #unstemmed_searchable
|
221
267
|
}
|
222
268
|
end
|
223
269
|
end
|
224
|
-
|
225
|
-
def silence
|
226
|
-
old_level = @mapper.logger.level
|
227
|
-
@mapper.logger.level = 100
|
228
|
-
begin
|
229
|
-
yield
|
230
|
-
ensure
|
231
|
-
@mapper.logger.level = old_level
|
232
|
-
end
|
233
|
-
end
|
234
270
|
end
|
@@ -2,25 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Solrizer::XML::Extractor do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
@extractor = Solrizer::Extractor.new
|
7
7
|
end
|
8
|
+
|
9
|
+
let(:result) { @extractor.xml_to_solr(fixture("druid-bv448hq0314-descMetadata.xml"))}
|
8
10
|
|
9
11
|
describe ".xml_to_solr" do
|
10
12
|
it "should turn simple xml into a solr document" do
|
11
|
-
|
12
|
-
|
13
|
-
result
|
14
|
-
result[:
|
15
|
-
result[:
|
16
|
-
result[:
|
17
|
-
result[:
|
18
|
-
result[:
|
19
|
-
result[:
|
20
|
-
result[:
|
21
|
-
result[:format_t].should include("application/jp2000")
|
22
|
-
result[:title_t].should == "This is a Sample Title"
|
23
|
-
result[:publisher_t].should == "Sample Unversity"
|
13
|
+
result[:type_tesim].should == "text"
|
14
|
+
result[:medium_tesim].should == "Paper Document"
|
15
|
+
result[:rights_tesim].should == "Presumed under copyright. Do not publish."
|
16
|
+
result[:date_tesim].should == "1985-12-30"
|
17
|
+
result[:format_tesim].should be_kind_of(Array)
|
18
|
+
result[:format_tesim].should include("application/tiff")
|
19
|
+
result[:format_tesim].should include("application/pdf")
|
20
|
+
result[:format_tesim].should include("application/jp2000")
|
21
|
+
result[:title_tesim].should == "This is a Sample Title"
|
22
|
+
result[:publisher_tesim].should == "Sample Unversity"
|
24
23
|
|
25
24
|
end
|
26
25
|
end
|
@@ -26,7 +26,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
26
26
|
|
27
27
|
it "should iterate through the terminology terms, calling .solrize_term on each and passing in the solr doc" do
|
28
28
|
solr_doc = Hash.new
|
29
|
-
@mods_article.field_mapper = Solrizer::FieldMapper
|
29
|
+
@mods_article.field_mapper = Solrizer::FieldMapper.new
|
30
30
|
Samples::ModsArticle.terminology.terms.each_pair do |k,v|
|
31
31
|
@mods_article.should_receive(:solrize_term).with(v, solr_doc, @mods_article.field_mapper)
|
32
32
|
end
|
@@ -37,16 +37,16 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
37
37
|
|
38
38
|
solr_doc = @mods_article.to_solr
|
39
39
|
solr_doc["abstract"].should be_nil
|
40
|
-
solr_doc["
|
41
|
-
solr_doc["
|
42
|
-
solr_doc["
|
40
|
+
solr_doc["abstract_tesim"].should == ["ABSTRACT"]
|
41
|
+
solr_doc["title_info_1_language_tesim"].should == ["finnish"]
|
42
|
+
solr_doc["person_1_role_0_text_tesim"].should == ["teacher"]
|
43
43
|
# No index_as on the code field.
|
44
|
-
solr_doc["
|
45
|
-
solr_doc["
|
46
|
-
solr_doc["
|
44
|
+
solr_doc["person_1_role_0_code_tesim"].should be_nil
|
45
|
+
solr_doc["person_last_name_tesim"].sort.should == ["FAMILY NAME", "Gautama"]
|
46
|
+
solr_doc["topic_tag_tesim"].sort.should == ["CONTROLLED TERM", "TOPIC 1", "TOPIC 2"]
|
47
47
|
|
48
48
|
# These are a holdover from an old verison of OM
|
49
|
-
solr_doc['
|
49
|
+
solr_doc['journal_0_issue_0_publication_date_dtsi'].should == ["2007-02-01T00:00:00Z"]
|
50
50
|
|
51
51
|
|
52
52
|
end
|
@@ -69,7 +69,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
69
69
|
@mods_article.solrize_term(term, fake_solr_doc)
|
70
70
|
|
71
71
|
expected_names = ["DR.", "FAMILY NAME", "GIVEN NAMES"]
|
72
|
-
%w(
|
72
|
+
%w(_tesim _sim).each do |suffix|
|
73
73
|
actual_names = fake_solr_doc["name_0_namePart#{suffix}"].sort
|
74
74
|
{suffix => actual_names}.should == {suffix => expected_names}
|
75
75
|
end
|
@@ -79,14 +79,14 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
79
79
|
unless RUBY_VERSION.match("1.8.7")
|
80
80
|
solr_doc = Hash.new
|
81
81
|
result = @mods_article.solrize_term(Samples::ModsArticle.terminology.retrieve_term(:pub_date), solr_doc)
|
82
|
-
solr_doc["
|
82
|
+
solr_doc["pub_date_dtsi"].should == ["2007-02-01T00:00:00Z"]
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should add fields based on type using ref" do
|
87
87
|
solr_doc = Hash.new
|
88
88
|
result = @mods_article.solrize_term(Samples::ModsArticle.terminology.retrieve_term(:issue_date), solr_doc)
|
89
|
-
solr_doc["
|
89
|
+
solr_doc["issue_date_dtsi"].should == ["2007-02-15T00:00:00Z"]
|
90
90
|
end
|
91
91
|
|
92
92
|
it "shouldn't index terms where index_as is an empty array" do
|
@@ -95,7 +95,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
95
95
|
term.children[:namePart].index_as = []
|
96
96
|
|
97
97
|
@mods_article.solrize_term(term, fake_solr_doc)
|
98
|
-
fake_solr_doc["
|
98
|
+
fake_solr_doc["name_0_namePart_tesim"].should be_nil
|
99
99
|
end
|
100
100
|
|
101
101
|
it "shouldn't index terms where index_as is searchable" do
|
@@ -105,16 +105,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
105
105
|
|
106
106
|
@mods_article.solrize_term(term, fake_solr_doc)
|
107
107
|
|
108
|
-
fake_solr_doc["
|
108
|
+
fake_solr_doc["name_0_namePart_tesim"].sort.should == ["DR.", "FAMILY NAME", "GIVEN NAMES"]
|
109
109
|
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
describe ".solrize_node" do
|
114
|
-
it "should optionally allow you to provide the Hash to add fields to and return that document when done"
|
115
|
-
it "should create a solr field containing node.text"
|
116
|
-
it "should create hierarchical field entries if parents is not empty"
|
117
|
-
it "should only create one node if parents is empty"
|
118
110
|
end
|
119
|
-
|
120
111
|
end
|