Module: Stanford::Mods::SearchworksSubjects

Included in:
Record
Defined in:
lib/stanford-mods/concerns/searchworks_subjects.rb

Instance Method Summary collapse

Instance Method Details

#era_facetArray<String>

subject/temporal values with trailing comma, semicolon, and backslash (and any preceding spaces) removed

Returns:

  • (Array<String>)

    values for the era_facet Solr field for this document or nil if none



33
34
35
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 33

def era_facet
  strip_punctuation(subject_temporal)
end

#geographic_facetArray<String>

geographic_search values with trailing comma, semicolon, and backslash (and any preceding spaces) removed

Returns:

  • (Array<String>)

    values for the geographic_facet Solr field for this document or nil if none



27
28
29
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 27

def geographic_facet
  strip_punctuation(geographic_search)
end

#geographic_searchArray<String>

Values are the contents of:

subject/geographic
subject/hierarchicalGeographic
subject/geographicCode  (only include the translated value if it isn't already present from other mods geo fields)

Returns:

  • (Array<String>)

    values for the geographic_search Solr field for this document or nil if none



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 42

def geographic_search
  result = term_values([:subject, :geographic]) || []

  # hierarchicalGeographic has sub elements
  hierarchical_vals = mods_ng_xml.subject.hierarchicalGeographic.map do |hg_node|
    hg_vals = hg_node.element_children.map(&:text).reject(&:empty?)
    hg_vals.join(' ') unless hg_vals.empty?
  end

  trans_code_vals = mods_ng_xml.subject.geographicCode.translated_value || []

  (result + hierarchical_vals + trans_code_vals).compact.uniq
end

#subject_all_searchArray<String>

Values are the contents of:

all subject subelements except subject/cartographic plus  genre top level element

Returns:

  • (Array<String>)

    values for the subject_all_search Solr field for this document or nil if none



79
80
81
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 79

def subject_all_search
  topic_search + geographic_search + subject_other_search + subject_other_subvy_search
end

#subject_other_searchArray<String>

Values are the contents of:

subject/name
subject/occupation  - no subelements
subject/titleInfo

Returns:

  • (Array<String>)

    values for the subject_other_search Solr field for this document or nil if none



61
62
63
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 61

def subject_other_search
  subject_occupations + subject_names + subject_titles
end

#subject_other_subvy_searchArray<String>

Values are the contents of:

subject/temporal
subject/genre

Returns:

  • (Array<String>)

    values for the subject_other_subvy_search Solr field for this document or nil if none



69
70
71
72
73
74
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 69

def subject_other_subvy_search
  vals = Array(subject_temporal)
  gvals = term_values([:subject, :genre])

  vals + Array(gvals)
end

#topic_facetArray<String>

Values are the contents of:

 subject/topic
 subject/name
 subject/title
 subject/occupation
with trailing comma, semicolon, and backslash (and any preceding spaces) removed

Returns:

  • (Array<String>)

    values for the topic_facet Solr field for this document or nil if none



21
22
23
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 21

def topic_facet
  strip_punctuation(subject_topics + subject_names + subject_titles + subject_occupations)
end

#topic_searchArray<String>

Values are the contents of:

mods/subject/topic

Returns:

  • (Array<String>)

    values for the topic_search Solr field for this document or nil if none



10
11
12
# File 'lib/stanford-mods/concerns/searchworks_subjects.rb', line 10

def topic_search
  subject_topics
end