Module: Solrizer::DefaultDescriptors

Defined in:
lib/cul_hydra/solrizer_patch.rb

Defined Under Namespace

Modules: Normal Classes: MarcCodeTextableDescriptor, ProjectFacetDescriptor, ProjectTextableDescriptor, TextableDescriptor

Class Method Summary collapse

Class Method Details

.date_sortableObject



3
4
5
# File 'lib/cul_hydra/solrizer_patch.rb', line 3

def self.date_sortable
  @date_sortable ||= Solrizer::Descriptor.new(:date, :stored, :indexed, converter: date_sortable_converter)
end

.date_sortable_converterObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cul_hydra/solrizer_patch.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_hydra/solrizer_patch.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.expand_path(config_path)}")
      return {}
    end
  end
  logger.info("ValueMapper: loading field value maps from #{File.expand_path(config_path)}")
  YAML::load(File.open(config_path))
end

.marc_code_textableObject

Produces all_text_timv fieldname and a value-mapping converter



32
33
34
# File 'lib/cul_hydra/solrizer_patch.rb', line 32

def self.marc_code_textable
  @marc_code_map_text_type ||= MarcCodeTextableDescriptor.new(:text_en, :indexed, :multivalued)
end

.project_facetableObject

Produces _sim suffix



13
14
15
# File 'lib/cul_hydra/solrizer_patch.rb', line 13

def self.project_facetable
  @project_facet_type ||= ProjectFacetDescriptor.new(:string, :indexed, :multivalued)
end

.project_textableObject



17
18
19
# File 'lib/cul_hydra/solrizer_patch.rb', line 17

def self.project_textable
  @project_textable_type ||= ProjectTextableDescriptor.new(:text_en, :indexed, :multivalued)
end

.textableObject

Produces the field name ‘all_text_teim’



8
9
10
# File 'lib/cul_hydra/solrizer_patch.rb', line 8

def self.textable
  @textable_type ||= TextableDescriptor.new(:text_en, :indexed, :multivalued)
end

.value_mapsObject



55
56
57
# File 'lib/cul_hydra/solrizer_patch.rb', line 55

def self.value_maps
  @@value_maps ||= load_value_maps
end