Class: Valkyrie::Persistence::Solr::ModelConverter::StringPropertyValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/solr/model_converter.rb

Overview

Handles casting strings.

Instance Attribute Summary

Attributes inherited from ValueMapper

#calling_mapper, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValueMapper

for, #initialize, register

Constructor Details

This class inherits a constructor from Valkyrie::ValueMapper

Class Method Details

.handles?(value) ⇒ Boolean

Determines whether or not a Property value is a String

Parameters:

  • value (Object)

Returns:

  • (Boolean)


402
403
404
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 402

def self.handles?(value)
  value.is_a?(Property) && value.value.is_a?(String)
end

Instance Method Details

#fieldsArray<Symbol>

Generates the Solr fields used during the indexing String are normally indexed using the following:

- stored text
- stored english text
- stored single string
- multivalued string
- stored multivalued text
- stored multivalued english text

If the string is greater than 1000 characters in length, it is only indexed as a stored multivalued text



424
425
426
427
428
429
430
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 424

def fields
  if value.value.length > 1000
    [:tsim]
  else
    [:tsim, :ssim, :tesim, :tsi, :ssi, :tesi]
  end
end

#resultSolrRow

Constructs a SolrRow object with the String values and Solr field settings

Returns:



408
409
410
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 408

def result
  SolrRow.new(key: value.key, fields: fields, values: [value.value])
end