Module: Solrizer::DefaultDescriptors
- Defined in:
- lib/cul_scv_hydra/solrizer/field_mapper.rb
Defined Under Namespace
Modules: Normal Classes: MarcCodeDisplayDescriptor, MarcCodeFacetDescriptor, MarcCodeTextableDescriptor, ProjectFacetDescriptor, ProjectTextableDescriptor, TextableDescriptor
Class Method Summary collapse
- .date_sortable ⇒ Object
- .date_sortable_converter ⇒ Object
- .load_value_maps(config_path = nil) ⇒ Object
-
.marc_code_displayable ⇒ Object
Produces _ssm suffix and a value-mapping converter.
-
.marc_code_facetable ⇒ Object
Produces _sim suffix and a value-mapping converter.
-
.marc_code_textable ⇒ Object
Produces all_text_timv fieldname and a value-mapping converter.
-
.project_facetable ⇒ Object
Produces _sim suffix.
- .project_textable ⇒ Object
-
.textable ⇒ Object
Produces the field name ‘all_text_teim’.
- .value_maps ⇒ Object
Class Method Details
.date_sortable ⇒ Object
3 4 5 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 3 def self.date_sortable @date_sortable ||= Solrizer::Descriptor.new(:date, :stored, :indexed, converter: date_sortable_converter) end |
.date_sortable_converter ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 59 def self.date_sortable_converter lambda do |type| lambda do |val| begin d = val.length < 11 ? Date.new(*(val.split('-').collect {|s| s.to_i})) : Date.parse(val) iso8601_date(d) rescue ArgumentError nil end end end end |
.load_value_maps(config_path = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 36 def self.load_value_maps(config_path=nil) if config_path.nil? if defined?(Rails.root) && !Rails.root.nil? config_path = File.join(Rails.root, "config", "solr_value_maps.yml") end # Default to using the config file within the gem if !File.exist?(config_path.to_s) logger.warn("ValueMapper: no field value maps at #{config_path}") config_path = File.join(File.dirname(__FILE__), "..", "..", "..", "config", "solr_value_maps.yml") end if !File.exist?(config_path.to_s) logger.warn("ValueMapper: no field value maps at #{File.(config_path)}") return {} end end logger.info("ValueMapper: loading field value maps from #{File.(config_path)}") YAML::load(File.open(config_path)) end |
.marc_code_displayable ⇒ Object
Produces _ssm suffix and a value-mapping converter
27 28 29 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 27 def self.marc_code_displayable @marc_code_type ||= MarcCodeDisplayDescriptor.new(:string, :stored, :indexed, :multivalued) end |
.marc_code_facetable ⇒ Object
Produces _sim suffix and a value-mapping converter
22 23 24 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 22 def self.marc_code_facetable @marc_code_facet_type ||= MarcCodeFacetDescriptor.new(:string, :indexed, :multivalued) end |
.marc_code_textable ⇒ Object
Produces all_text_timv fieldname and a value-mapping converter
32 33 34 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 32 def self.marc_code_textable @marc_code_map_text_type ||= MarcCodeTextableDescriptor.new(:text_en, :indexed, :multivalued) end |
.project_facetable ⇒ Object
Produces _sim suffix
13 14 15 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 13 def self.project_facetable @project_facet_type ||= ProjectFacetDescriptor.new(:string, :indexed, :multivalued) end |
.project_textable ⇒ Object
17 18 19 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 17 def self.project_textable @project_textable_type ||= ProjectTextableDescriptor.new(:text_en, :indexed, :multivalued) end |
.textable ⇒ Object
Produces the field name ‘all_text_teim’
8 9 10 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 8 def self.textable @textable_type ||= TextableDescriptor.new(:text_en, :indexed, :multivalued) end |
.value_maps ⇒ Object
55 56 57 |
# File 'lib/cul_scv_hydra/solrizer/field_mapper.rb', line 55 def self.value_maps @@value_maps ||= load_value_maps end |