class ActiveFedora::Indexing::DefaultDescriptors

Public Class Methods

dateable() click to toggle source

Takes fields which are stored as strings, but we want indexed as dates. (e.g. “November 6th, 2012”) produces suffixes:

_dtsim - for dates
# File lib/active_fedora/indexing/default_descriptors.rb, line 23
def self.dateable
  @dateable ||= Descriptor.new(:date, :stored, :indexed, :multivalued, converter: dateable_converter)
end
dateable_converter() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 104
def dateable_converter
  lambda do |_type|
    lambda do |val|
      iso8601_date(Date.parse(val))
    rescue ArgumentError
      nil
    end
  end
end
displayable() click to toggle source

Produces _ssm suffix

# File lib/active_fedora/indexing/default_descriptors.rb, line 55
def self.displayable
  @displayable ||= Descriptor.new(:string, :stored, :multivalued)
end
facetable() click to toggle source

Produces _sim suffix

# File lib/active_fedora/indexing/default_descriptors.rb, line 28
def self.facetable
  @facetable ||= Descriptor.new(:string, :indexed, :multivalued)
end
iso8601_date(value) click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 114
def iso8601_date(value)
  if value.is_a?(Date) || value.is_a?(Time)
    DateTime.parse(value.to_s).to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
  elsif !value.empty?
    DateTime.parse(value).to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
  end
rescue ArgumentError
  raise ArgumentError, "Unable to parse `#{value}' as a date-time object"
end
searchable() click to toggle source

The suffix produced depends on the type parameter – produces suffixes:

_teim - for strings or text fields
_dtim - for dates
_iim - for integers
# File lib/active_fedora/indexing/default_descriptors.rb, line 16
def self.searchable
  @searchable ||= Descriptor.new(searchable_field_definition, converter: searchable_converter, requires_type: true)
end
searchable_converter() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 95
def searchable_converter
  lambda do |type|
    case type
    when :date, :time
      ->(val) { iso8601_date(val) }
    end
  end
end
searchable_field_definition() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 69
def searchable_field_definition
  lambda do |type|
    type = :text_en if [:string, :text].include?(type) # for backwards compatibility with old solr schema
    vals = [type, :indexed, :multivalued]
    vals
  end
end
simple() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 64
def self.simple
  @simple ||= Descriptor.new(->(field_type) { [field_type, :indexed] })
end
sortable() click to toggle source

The suffix produced depends on the type parameter – produces suffixes:

_tei - for text fields
_si - for strings
_dti - for dates
_ii - for integers
# File lib/active_fedora/indexing/default_descriptors.rb, line 43
def self.sortable
  @sortable ||= Descriptor.new(sortable_field_definition, converter: searchable_converter, requires_type: true)
end
sortable_field_definition() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 88
def sortable_field_definition
  lambda do |type|
    vals = [type, :indexed]
    vals
  end
end
stored_searchable() click to toggle source

The suffix produced depends on the type parameter – produces suffixes:

_tesim - for strings or text fields
_dtsim - for dates
_isim - for integers
# File lib/active_fedora/indexing/default_descriptors.rb, line 8
def self.stored_searchable
  @stored_searchable ||= Descriptor.new(stored_searchable_field_definition, converter: searchable_converter, requires_type: true)
end
stored_searchable_field_definition() click to toggle source
# File lib/active_fedora/indexing/default_descriptors.rb, line 77
def stored_searchable_field_definition
  lambda do |type|
    type = :text_en if [:string, :text].include?(type) # for backwards compatibility with old solr schema
    if type == :boolean
      [type, :indexed, :stored]
    else
      [type, :indexed, :stored, :multivalued]
    end
  end
end
stored_sortable() click to toggle source

Fields that are both stored and sortable Produces _ssi suffix if field_type is string Produces _dtsi suffix if field_type is date

# File lib/active_fedora/indexing/default_descriptors.rb, line 50
def self.stored_sortable
  @stored_sortable ||= Descriptor.new(->(field_type) { [field_type, :stored, :indexed] }, converter: searchable_converter)
end
symbol() click to toggle source

Produces _ssim suffix This is useful for when you only want to match whole words, such as user/group names from the the rightsMetadata datastream

# File lib/active_fedora/indexing/default_descriptors.rb, line 34
def self.symbol
  @symbol ||= Descriptor.new(:string, :stored, :indexed, :multivalued)
end
unstemmed_searchable() click to toggle source

Produces _tim suffix (used to be _unstem)

# File lib/active_fedora/indexing/default_descriptors.rb, line 60
def self.unstemmed_searchable
  @unstemmed_searchable ||= Descriptor.new(:text, :indexed, :multivalued)
end