solrizer 2.0.0 → 2.1.0.rc1
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/History.txt +6 -0
- data/config/solr_mappings.yml +1 -2
- data/lib/solrizer.rb +9 -2
- data/lib/solrizer/common.rb +38 -0
- data/lib/solrizer/field_mapper.rb +59 -26
- data/lib/solrizer/field_name_mapper.rb +8 -5
- data/lib/solrizer/version.rb +1 -1
- data/lib/solrizer/xml/terminology_based_solrizer.rb +72 -69
- data/solrizer.gemspec +1 -0
- data/spec/fixtures/mods_article.rb +2 -2
- data/spec/units/common_spec.rb +39 -0
- data/spec/units/field_mapper_spec.rb +8 -8
- data/spec/units/xml_terminology_based_solrizer_spec.rb +3 -17
- metadata +24 -8
- data/config/fedora.yml +0 -16
- data/config/hydra_types.yml +0 -4
- data/config/solr.yml +0 -7
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
h2. 2.1.0
|
2
|
+
#11 There should only be one instance of the field mapper. It's now at Solrizer.default_field_mapper
|
3
|
+
Extract create_and_insert_terms into Solrizer::Common. This can be used for RDF datastreams
|
4
|
+
Raise helpful error message if date can't be parsed.
|
5
|
+
Don't add searchable terms when another kind of field is added (continuation of HYDRA-827)
|
6
|
+
|
1
7
|
h2. 2.0.0
|
2
8
|
HYDRA-827 DO NOT index terms by default
|
3
9
|
HYDRA-863 Null pointer exception fixed.
|
data/config/solr_mappings.yml
CHANGED
data/lib/solrizer.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
module Solrizer
|
3
2
|
def self.version
|
4
3
|
Solrizer::VERSION
|
5
4
|
end
|
5
|
+
|
6
|
+
def self.default_field_mapper
|
7
|
+
@@default_field_mapper ||= Solrizer::FieldMapper::Default.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.default_field_mapper=(field_mapper)
|
11
|
+
@@default_field_mapper = field_mapper
|
12
|
+
end
|
13
|
+
|
6
14
|
end
|
7
15
|
|
8
16
|
require "solrizer/extractor"
|
9
|
-
# Dir[File.join(File.dirname(__FILE__),"solrizer","*.rb")].each {|file| require file }
|
10
17
|
Dir[File.join(File.dirname(__FILE__),"solrizer","*.rb")].each do |file|
|
11
18
|
require "solrizer/"+File.basename(file, File.extname(file)) unless file.match(/railtie.rb$/)
|
12
19
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# The goal of this method is to have no dependency on OM, so that NOM or RDF datastreams could use this.
|
2
|
+
|
3
|
+
module Solrizer
|
4
|
+
# Instructions on how to solrize the field (types and uses)
|
5
|
+
class Directive
|
6
|
+
attr_accessor :type, :index_as
|
7
|
+
def initialize(*args)
|
8
|
+
case args
|
9
|
+
when Hash
|
10
|
+
self.type = args[:type]
|
11
|
+
self.index_as = args[:index_as]
|
12
|
+
when Array
|
13
|
+
self.type = args[0]
|
14
|
+
self.index_as = args[1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Common
|
20
|
+
def self.included(klass)
|
21
|
+
klass.send(:extend, ClassMethods)
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
# @param [String] field_name_base the name of the solr field (without the type suffix)
|
26
|
+
# @param [Object] value the value to insert into the document
|
27
|
+
# @param [Directive] directive instructions on which fields to create
|
28
|
+
# @param [Hash] solr_doc the solr_doc to insert into.
|
29
|
+
def create_and_insert_terms(field_name_base, value, directive, solr_doc)
|
30
|
+
Solrizer.default_field_mapper.solr_names_and_values(field_name_base, value, directive.type, directive.index_as).each do |field_name, field_value|
|
31
|
+
unless field_value.join("").strip.empty?
|
32
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_name, field_value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "loggable"
|
2
|
+
require 'active_support'
|
2
3
|
module Solrizer
|
3
4
|
|
4
5
|
# Maps Term names and values to Solr fields, based on the Term's data type and any index_as options.
|
@@ -186,6 +187,12 @@ module Solrizer
|
|
186
187
|
end
|
187
188
|
end
|
188
189
|
end
|
190
|
+
|
191
|
+
# Reset all of the mappings
|
192
|
+
def self.clear_mappings
|
193
|
+
logger.debug "resetting mappings for #{self.to_s}"
|
194
|
+
@@instance_init_actions[self] = []
|
195
|
+
end
|
189
196
|
|
190
197
|
private
|
191
198
|
|
@@ -204,11 +211,6 @@ module Solrizer
|
|
204
211
|
end
|
205
212
|
end
|
206
213
|
|
207
|
-
# Reset all of the mappings
|
208
|
-
def self.clear_mappings
|
209
|
-
logger.debug "resetting mappings for #{self.to_s}"
|
210
|
-
@@instance_init_actions[self] = []
|
211
|
-
end
|
212
214
|
|
213
215
|
public
|
214
216
|
|
@@ -326,30 +328,61 @@ module Solrizer
|
|
326
328
|
|
327
329
|
public
|
328
330
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
331
|
+
module Defaults
|
332
|
+
extend ActiveSupport::Concern
|
333
|
+
included do
|
334
|
+
id_field 'id'
|
335
|
+
index_as :searchable do |t|
|
336
|
+
t.default :suffix => '_t'
|
337
|
+
t.date :suffix => '_dt' do |value|
|
338
|
+
iso8601_date(value)
|
339
|
+
end
|
340
|
+
t.string :suffix => '_t'
|
341
|
+
t.text :suffix => '_t'
|
342
|
+
t.symbol :suffix => '_s'
|
343
|
+
t.integer :suffix => '_i'
|
344
|
+
t.long :suffix => '_l'
|
345
|
+
t.boolean :suffix => '_b'
|
346
|
+
t.float :suffix => '_f'
|
347
|
+
t.double :suffix => '_d'
|
348
|
+
end
|
349
|
+
index_as :displayable, :suffix => '_display' do |t|
|
350
|
+
t.date do |value|
|
351
|
+
value.to_s
|
338
352
|
end
|
339
353
|
end
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
354
|
+
index_as :facetable, :suffix => '_facet' do |t|
|
355
|
+
t.date do |value|
|
356
|
+
value.to_s
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
index_as :sortable, :suffix => '_sort' do |t|
|
361
|
+
t.date do |value|
|
362
|
+
value.to_s
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
index_as :unstemmed_searchable, :suffix => '_unstem_search'
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
class Default < FieldMapper
|
371
|
+
include Defaults
|
372
|
+
end
|
373
|
+
|
374
|
+
protected
|
375
|
+
|
376
|
+
def self.iso8601_date(value)
|
377
|
+
begin
|
378
|
+
if value.is_a?(Date)
|
379
|
+
DateTime.parse(value.to_s).to_time.utc.iso8601
|
380
|
+
elsif !value.empty?
|
381
|
+
DateTime.parse(value).to_time.utc.iso8601
|
382
|
+
end
|
383
|
+
rescue ArgumentError => e
|
384
|
+
raise ArgumentError, "Unable to parse `#{value}' as a date-time object"
|
348
385
|
end
|
349
|
-
index_as :displayable, :suffix => '_display'
|
350
|
-
index_as :facetable, :suffix => '_facet'
|
351
|
-
index_as :sortable, :suffix => '_sort'
|
352
|
-
index_as :unstemmed_searchable, :suffix => '_unstem_search'
|
353
386
|
end
|
354
387
|
|
355
388
|
end
|
@@ -15,7 +15,10 @@ module Solrizer::FieldNameMapper
|
|
15
15
|
# Re-loads solr mappings for the default field mapper's class
|
16
16
|
# and re-sets the default field mapper to an FieldMapper instance with those mappings.
|
17
17
|
def load_mappings( config_path=nil)
|
18
|
-
|
18
|
+
# Dynamically create a new class?
|
19
|
+
self.default_field_mapper.class.clear_mappings
|
20
|
+
self.default_field_mapper.class.send(:include, Solrizer::FieldMapper::Defaults)
|
21
|
+
self.default_field_mapper.class.load_mappings(config_path) if config_path
|
19
22
|
self.default_field_mapper = self.default_field_mapper.class.new
|
20
23
|
end
|
21
24
|
|
@@ -24,11 +27,11 @@ module Solrizer::FieldNameMapper
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def default_field_mapper
|
27
|
-
|
30
|
+
Solrizer.default_field_mapper
|
28
31
|
end
|
29
32
|
|
30
|
-
def default_field_mapper=(
|
31
|
-
|
33
|
+
def default_field_mapper=(obj)
|
34
|
+
Solrizer.default_field_mapper = obj
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -45,4 +48,4 @@ module Solrizer::FieldNameMapper
|
|
45
48
|
self.class.solr_name(field_name, field_type, index_type)
|
46
49
|
end
|
47
50
|
|
48
|
-
end
|
51
|
+
end
|
data/lib/solrizer/version.rb
CHANGED
@@ -1,101 +1,104 @@
|
|
1
1
|
# This module is only suitable to mix into Classes that use the OM::XML::Document Module
|
2
2
|
module Solrizer::XML::TerminologyBasedSolrizer
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
def self.included(klass)
|
4
|
+
klass.send(:include, Solrizer::Common)
|
5
|
+
klass.send(:extend, ClassMethods)
|
6
6
|
end
|
7
7
|
|
8
8
|
# Module Methods
|
9
|
+
module ClassMethods
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
# Build a solr document from +doc+ based on its terminology
|
12
|
+
# @param [OM::XML::Document] doc
|
13
|
+
# @param [Hash] (optional) solr_doc (values hash) to populate
|
14
|
+
def solrize(doc, solr_doc=Hash.new, field_mapper = nil)
|
15
|
+
unless doc.class.terminology.nil?
|
16
|
+
doc.class.terminology.terms.each_pair do |term_name,term|
|
17
|
+
doc.solrize_term(term, solr_doc, field_mapper)
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# Populate a solr document with fields based on nodes in +xml+
|
24
|
-
# Values for a term are gathered by to +term_pointer+ using OM::XML::TermValueOperators.term_values
|
25
|
-
# and are deserialized by OM according to :type, as determined in its terminology.
|
26
|
-
# The content of the actual field in solr is each +node+ of the +nodeset+ returned by OM,
|
27
|
-
# rendered to a string.
|
28
|
-
# @param [OM::XML::Document] doc xml document to extract values from
|
29
|
-
# @param [OM::XML::Term] term corresponding to desired xml values
|
30
|
-
# @param [Hash] (optional) solr_doc (values hash) to populate
|
31
|
-
def self.solrize_term(doc, term, solr_doc = Hash.new, field_mapper = nil, opts={})
|
32
|
-
parents = opts.fetch(:parents, [])
|
33
|
-
term_pointer = parents+[term.name]
|
34
|
-
nodeset = doc.term_values(*term_pointer)
|
21
|
+
return solr_doc
|
22
|
+
end
|
35
23
|
|
36
|
-
|
24
|
+
# Populate a solr document with fields based on nodes in +xml+
|
25
|
+
# Values for a term are gathered by to +term_pointer+ using OM::XML::TermValueOperators.term_values
|
26
|
+
# and are deserialized by OM according to :type, as determined in its terminology.
|
27
|
+
# The content of the actual field in solr is each +node+ of the +nodeset+ returned by OM,
|
28
|
+
# rendered to a string.
|
29
|
+
# @param [OM::XML::Document] doc xml document to extract values from
|
30
|
+
# @param [OM::XML::Term] term corresponding to desired xml values
|
31
|
+
# @param [Hash] (optional) solr_doc (values hash) to populate
|
32
|
+
def solrize_term(doc, term, solr_doc = Hash.new, field_mapper = nil, opts={})
|
33
|
+
parents = opts.fetch(:parents, [])
|
34
|
+
term_pointer = parents+[term.name]
|
35
|
+
nodeset = doc.term_values(*term_pointer)
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
nodeset.each do |n|
|
38
|
+
|
39
|
+
# TODO: Solrizer::FieldMapper::Default is supposed to translate dates into full ISO 8601 formatted strings.
|
40
|
+
# However, there an integration issue with ActiveFedora using OM: it ignores the default field mapper given
|
41
|
+
# in this gem that does this. So, the following is a workaround until it is fixed.
|
42
|
+
node = n.is_a?(Date) ? DateTime.parse(n.to_s).to_time.utc.iso8601 : n.to_s
|
43
|
+
|
44
|
+
doc.solrize_node(node.to_s, term_pointer, term, solr_doc, field_mapper)
|
45
|
+
unless term.kind_of? OM::XML::NamedTermProxy
|
46
|
+
term.children.each_pair do |child_term_name, child_term|
|
47
|
+
doc.solrize_term(child_term, solr_doc, field_mapper, opts={:parents=>parents+[{term.name=>nodeset.index(node.to_s)}]})
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
51
|
+
solr_doc
|
49
52
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
::
|
53
|
+
|
54
|
+
# Populate a solr document with solr fields corresponding to the given xml node
|
55
|
+
# Field names are generated using settings from the term in the +doc+'s terminology corresponding to +term_pointer+
|
56
|
+
# If the supplied term does not have an index_as attribute, no indexing will be performed.
|
57
|
+
# @param [Nokogiri::XML::Node] node to solrize
|
58
|
+
# @param [OM::XML::Document] doc document the node came from
|
59
|
+
# @param [Array] term_pointer Array pointing to the term that should be used for solrization settings
|
60
|
+
# @param [Term] term the term to be solrized
|
61
|
+
# @param [Hash] (optional) solr_doc (values hash) to populate
|
62
|
+
# @return [Hash] the solr doc
|
63
|
+
def solrize_node(node_value, doc, term_pointer, term, solr_doc = Hash.new, field_mapper = nil, opts = {})
|
64
|
+
return solr_doc unless term.index_as && !term.index_as.empty?
|
65
|
+
|
66
|
+
directive = term_to_solrizer_directive(term)
|
67
|
+
|
68
|
+
generic_field_name_base = OM::XML::Terminology.term_generic_name(*term_pointer)
|
69
|
+
create_and_insert_terms(generic_field_name_base, node_value, directive, solr_doc)
|
70
|
+
|
71
|
+
|
72
|
+
if term_pointer.length > 1
|
73
|
+
hierarchical_field_name_base = OM::XML::Terminology.term_hierarchical_name(*term_pointer)
|
74
|
+
create_and_insert_terms(hierarchical_field_name_base, node_value, directive, solr_doc)
|
71
75
|
end
|
76
|
+
solr_doc
|
72
77
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_name, field_value)
|
79
|
-
end
|
80
|
-
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def term_to_solrizer_directive(term)
|
82
|
+
Solrizer::Directive.new(term.type, term.index_as)
|
81
83
|
end
|
82
|
-
|
84
|
+
|
83
85
|
end
|
86
|
+
|
84
87
|
|
85
88
|
# Instance Methods
|
86
89
|
|
87
90
|
attr_accessor :field_mapper
|
88
91
|
|
89
92
|
def to_solr(solr_doc = Hash.new, field_mapper = self.field_mapper) # :nodoc:
|
90
|
-
|
93
|
+
self.class.solrize(self, solr_doc, field_mapper)
|
91
94
|
end
|
92
95
|
|
93
96
|
def solrize_term(term, solr_doc = Hash.new, field_mapper = self.field_mapper, opts={})
|
94
|
-
|
97
|
+
self.class.solrize_term(self, term, solr_doc, field_mapper, opts)
|
95
98
|
end
|
96
99
|
|
97
100
|
def solrize_node(node, term_pointer, term, solr_doc = Hash.new, field_mapper = self.field_mapper, opts={})
|
98
|
-
|
101
|
+
self.class.solrize_node(node, self, term_pointer, term, solr_doc, field_mapper, opts)
|
99
102
|
end
|
100
103
|
|
101
104
|
end
|
data/solrizer.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency "mediashelf-loggable", "~>0.4.7"
|
19
19
|
s.add_dependency "stomp"
|
20
20
|
s.add_dependency "daemons"
|
21
|
+
s.add_dependency "activesupport"
|
21
22
|
s.add_development_dependency 'rspec', '~>2.0'
|
22
23
|
s.add_development_dependency 'rake'
|
23
24
|
s.add_development_dependency 'yard'
|
@@ -13,7 +13,7 @@ module Samples
|
|
13
13
|
}
|
14
14
|
t.french_title(:ref=>[:title_info,:main_title], :attributes=>{"xml:lang"=>"fre"})
|
15
15
|
|
16
|
-
t.language(:index_as=>[:facetable],:path=>{:attribute=>"lang"})
|
16
|
+
t.language(:index_as=>[:facetable, :searchable],:path=>{:attribute=>"lang"})
|
17
17
|
}
|
18
18
|
t.language{
|
19
19
|
t.lang_code(:index_as=>[:facetable], :path=>"languageTerm", :attributes=>{:type=>"code"})
|
@@ -22,7 +22,7 @@ module Samples
|
|
22
22
|
t.subject {
|
23
23
|
t.topic(:index_as=>[:facetable])
|
24
24
|
}
|
25
|
-
t.topic_tag(:proxy=>[:subject, :topic])
|
25
|
+
t.topic_tag(:proxy=>[:subject, :topic], :index_as=>[:searchable])
|
26
26
|
# t.topic_tag(:index_as=>[:facetable],:path=>"subject", :default_content_path=>"topic")
|
27
27
|
# This is a mods:name. The underscore is purely to avoid namespace conflicts.
|
28
28
|
t.name_ {
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Solrizer::Common do
|
4
|
+
before do
|
5
|
+
class Foo
|
6
|
+
include Solrizer::Common
|
7
|
+
end
|
8
|
+
end
|
9
|
+
after do
|
10
|
+
Object.send(:remove_const, :Foo)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should handle many field types" do
|
14
|
+
solr_doc = {}
|
15
|
+
directive = Solrizer::Directive.new(:string, [:displayable, :searchable, :sortable] )
|
16
|
+
Foo.create_and_insert_terms('my_name', 'value', directive, solr_doc)
|
17
|
+
solr_doc.should == {'my_name_t' => ['value'], 'my_name_sort' => ['value'], 'my_name_display' => ['value']}
|
18
|
+
end
|
19
|
+
it "should handle dates that are searchable" do
|
20
|
+
solr_doc = {}
|
21
|
+
directive = Solrizer::Directive.new(:date, [:searchable] )
|
22
|
+
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), directive, solr_doc)
|
23
|
+
solr_doc.should == {'my_name_dt' => ['2013-01-10T00:00:00Z']}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should handle dates that are displayable" do
|
27
|
+
solr_doc = {}
|
28
|
+
directive = Solrizer::Directive.new(:date, [:displayable])
|
29
|
+
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), directive, solr_doc)
|
30
|
+
solr_doc.should == {'my_name_display' => ['2013-01-10']}
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should handle dates that are sortable" do
|
34
|
+
solr_doc = {}
|
35
|
+
directive = Solrizer::Directive.new(:date, [:sortable])
|
36
|
+
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), directive, solr_doc)
|
37
|
+
solr_doc.should == {'my_name_sort' => ['2013-01-10']}
|
38
|
+
end
|
39
|
+
end
|
@@ -198,21 +198,21 @@ describe Solrizer::FieldMapper do
|
|
198
198
|
@mapper.id_field.should == 'id'
|
199
199
|
end
|
200
200
|
|
201
|
-
it "should apply mappings for searchable by default" do
|
201
|
+
it "should not apply mappings for searchable by default" do
|
202
202
|
# Just sanity check a couple; copy & pasting all data types is silly
|
203
|
-
@mapper.solr_names_and_values('foo', 'bar', :string, []).should == {
|
204
|
-
@mapper.solr_names_and_values('foo', "1", :integer, []).should == {
|
203
|
+
@mapper.solr_names_and_values('foo', 'bar', :string, []).should == { }
|
204
|
+
@mapper.solr_names_and_values('foo', "1", :integer, []).should == { }
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should support full ISO 8601 dates" do
|
208
|
-
@mapper.solr_names_and_values('foo', "2012-11-06", :date, []).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
209
|
-
@mapper.solr_names_and_values('foo', "November 6th, 2012", :date, []).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
210
|
-
@mapper.solr_names_and_values('foo', Date.parse("6 Nov. 2012"), :date, []).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
211
|
-
@mapper.solr_names_and_values('foo', '', :date, []).should == { 'foo_dt' => [] }
|
208
|
+
@mapper.solr_names_and_values('foo', "2012-11-06", :date, [:searchable]).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
209
|
+
@mapper.solr_names_and_values('foo', "November 6th, 2012", :date, [:searchable]).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
210
|
+
@mapper.solr_names_and_values('foo', Date.parse("6 Nov. 2012"), :date, [:searchable]).should == { 'foo_dt' =>["2012-11-06T00:00:00Z"] }
|
211
|
+
@mapper.solr_names_and_values('foo', '', :date, [:searchable]).should == { 'foo_dt' => [] }
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should support displayable, facetable, sortable, unstemmed" do
|
215
|
-
@mapper.solr_names_and_values('foo', 'bar', :string, [:displayable, :facetable, :sortable, :unstemmed_searchable]).should == {
|
215
|
+
@mapper.solr_names_and_values('foo', 'bar', :string, [:searchable, :displayable, :facetable, :sortable, :unstemmed_searchable]).should == {
|
216
216
|
'foo_t' => ['bar'],
|
217
217
|
'foo_display' => ['bar'],
|
218
218
|
'foo_facet' => ['bar'],
|
@@ -14,11 +14,6 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
14
14
|
|
15
15
|
describe ".to_solr" do
|
16
16
|
|
17
|
-
# after(:all) do
|
18
|
-
# # Revert to default mappings after running tests
|
19
|
-
# ActiveFedora::SolrService.load_mappings
|
20
|
-
# end
|
21
|
-
|
22
17
|
it "should provide .to_solr and return a SolrDocument" do
|
23
18
|
@mods_article.should respond_to(:to_solr)
|
24
19
|
@mods_article.to_solr.should be_kind_of(Hash)
|
@@ -30,8 +25,6 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
30
25
|
end
|
31
26
|
|
32
27
|
it "should iterate through the terminology terms, calling .solrize_term on each and passing in the solr doc" do
|
33
|
-
# mock_terms = {:name1=>:term1, :name2=>:term2}
|
34
|
-
# ActiveFedora::NokogiriDatastream.stubs(:accessors).returns(mock_accessors)
|
35
28
|
solr_doc = Hash.new
|
36
29
|
@mods_article.field_mapper = Solrizer::FieldMapper::Default.new
|
37
30
|
Samples::ModsArticle.terminology.terms.each_pair do |k,v|
|
@@ -43,8 +36,6 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
43
36
|
it "should use Solr mappings to generate field names" do
|
44
37
|
|
45
38
|
solr_doc = @mods_article.to_solr
|
46
|
-
#should have these
|
47
|
-
|
48
39
|
solr_doc["abstract"].should be_nil
|
49
40
|
solr_doc["abstract_t"].should == ["ABSTRACT"]
|
50
41
|
solr_doc["title_info_1_language_t"].should == ["finnish"]
|
@@ -68,13 +59,12 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
68
59
|
solr_doc = Hash.new
|
69
60
|
result = @mods_article.solrize_term(Samples::ModsArticle.terminology.retrieve_term(:title_info), solr_doc)
|
70
61
|
result.should == solr_doc
|
71
|
-
# @mods_article.solrize_term(:title_info, Samples::ModsArticle.terminology.retrieve_term(:title_info), :solr_doc=>solr_doc).should == ""
|
72
62
|
end
|
73
63
|
|
74
64
|
it "should add multiple fields based on index_as" do
|
75
65
|
fake_solr_doc = {}
|
76
66
|
term = Samples::ModsArticle.terminology.retrieve_term(:name)
|
77
|
-
term.children[:namePart].index_as = [:displayable, :facetable]
|
67
|
+
term.children[:namePart].index_as = [:searchable, :displayable, :facetable]
|
78
68
|
|
79
69
|
@mods_article.solrize_term(term, fake_solr_doc)
|
80
70
|
|
@@ -102,7 +92,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
102
92
|
it "shouldn't index terms where index_as is an empty array" do
|
103
93
|
fake_solr_doc = {}
|
104
94
|
term = Samples::ModsArticle.terminology.retrieve_term(:name)
|
105
|
-
term.children[:namePart].index_as = []
|
95
|
+
term.children[:namePart].index_as = []
|
106
96
|
|
107
97
|
@mods_article.solrize_term(term, fake_solr_doc)
|
108
98
|
fake_solr_doc["name_0_namePart_t"].should be_nil
|
@@ -121,11 +111,7 @@ describe Solrizer::XML::TerminologyBasedSolrizer do
|
|
121
111
|
end
|
122
112
|
|
123
113
|
describe ".solrize_node" do
|
124
|
-
it "should optionally allow you to provide the Hash to add fields to and return that document when done"
|
125
|
-
doc = Hash.new
|
126
|
-
# @mods_article.solrize_node(node, term_pointer, term, solr_doc).should equal(doc)
|
127
|
-
end
|
128
|
-
|
114
|
+
it "should optionally allow you to provide the Hash to add fields to and return that document when done"
|
129
115
|
it "should create a solr field containing node.text"
|
130
116
|
it "should create hierarchical field entries if parents is not empty"
|
131
117
|
it "should only create one node if parents is empty"
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solrizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Zumwalt
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -107,6 +107,22 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: activesupport
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
127
|
name: rspec
|
112
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,12 +207,10 @@ files:
|
|
191
207
|
- SOLRIZING_OM_DOCUMENTS.textile
|
192
208
|
- bin/solrizer
|
193
209
|
- bin/solrizerd
|
194
|
-
- config/fedora.yml
|
195
|
-
- config/hydra_types.yml
|
196
|
-
- config/solr.yml
|
197
210
|
- config/solr_mappings.yml
|
198
211
|
- config/solr_mappings_af_0.1.yml
|
199
212
|
- lib/solrizer.rb
|
213
|
+
- lib/solrizer/common.rb
|
200
214
|
- lib/solrizer/extractor.rb
|
201
215
|
- lib/solrizer/field_mapper.rb
|
202
216
|
- lib/solrizer/field_name_mapper.rb
|
@@ -219,6 +233,7 @@ files:
|
|
219
233
|
- spec/fixtures/mods_articles/hydrangea_article1.xml
|
220
234
|
- spec/fixtures/test_solr_mappings.yml
|
221
235
|
- spec/spec_helper.rb
|
236
|
+
- spec/units/common_spec.rb
|
222
237
|
- spec/units/extractor_spec.rb
|
223
238
|
- spec/units/field_mapper_spec.rb
|
224
239
|
- spec/units/field_name_mapper_spec.rb
|
@@ -239,9 +254,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
255
|
none: false
|
241
256
|
requirements:
|
242
|
-
- - ! '
|
257
|
+
- - ! '>'
|
243
258
|
- !ruby/object:Gem::Version
|
244
|
-
version:
|
259
|
+
version: 1.3.1
|
245
260
|
requirements: []
|
246
261
|
rubyforge_project:
|
247
262
|
rubygems_version: 1.8.24
|
@@ -259,6 +274,7 @@ test_files:
|
|
259
274
|
- spec/fixtures/mods_articles/hydrangea_article1.xml
|
260
275
|
- spec/fixtures/test_solr_mappings.yml
|
261
276
|
- spec/spec_helper.rb
|
277
|
+
- spec/units/common_spec.rb
|
262
278
|
- spec/units/extractor_spec.rb
|
263
279
|
- spec/units/field_mapper_spec.rb
|
264
280
|
- spec/units/field_name_mapper_spec.rb
|
data/config/fedora.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
fedora:
|
3
|
-
url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora
|
4
|
-
solr:
|
5
|
-
url: http://127.0.0.1:8983/solr/development
|
6
|
-
test:
|
7
|
-
fedora:
|
8
|
-
url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora
|
9
|
-
solr:
|
10
|
-
url: http://127.0.0.1:8983/solr/test
|
11
|
-
production:
|
12
|
-
fedora:
|
13
|
-
url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora
|
14
|
-
solr:
|
15
|
-
url: http://127.0.0.1:8080/solr
|
16
|
-
|
data/config/hydra_types.yml
DELETED