Skip to content

Commit

Permalink
Add date_full_ssim Solr filed
Browse files Browse the repository at this point in the history
Add at Entry document _date_full_ssim_ field to store full date string.
- it allows to sort Entries in date order including months and days
- it resolves some bug as reported at https://dti-uoy.atlassian.net/browse/TNW-30
  • Loading branch information
paluchas committed Jul 1, 2021
1 parent fe0e13c commit b65ce26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/new_solr_fields_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def modify_sdoc(sdoc)
# date_facet = get_date_array(get_id(sdoc[:id]))
date_facet = Indexer::DateFacetHelper.s_get_date_facets_from_entry(get_id(sdoc[:id]))

sdoc['date_facet_ssim'] = date_facet
sdoc['date_facet_ssim'] = date_facet[0] unless date_facet.blank?
sdoc['date_full_ssim'] = date_facet[1] unless date_facet.blank?

# Store SingleDate in single Solr dynamic field e.g. *_ssi (Note *_dttsi requieres dates in ISO format)
# Downcase occassional dates with comments
Expand Down
5 changes: 4 additions & 1 deletion app/helpers/indexer/date_facet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def self.s_get_date_facets_from_solr_doc(solr_doc)
# The prefix 's_' is the convention here, means retrieving data from Solr
# e.g.
# pry(main)> Indexer::DateFacetHelper.s_get_date_facets_from_entry('7p88cm19w')
# => [["1398", "1398"], ["1398/08/24", "1398/09/05"]]
def self.s_get_date_facets_from_entry(entry_id)
date_facets = []
date_full = []

# Find linked EntryDates
query = 'has_model_ssim:EntryDate AND entryDateFor_ssim:' + entry_id
Expand All @@ -30,12 +32,13 @@ def self.s_get_date_facets_from_entry(entry_id)
if single_date.include? 'date_tesim'
single_date['date_tesim'].each do |dt|
date_facets << dt.split('/')[0]
date_full << dt
end
end
end
end

date_facets
[date_facets, date_full]
end

end
Expand Down

0 comments on commit b65ce26

Please sign in to comment.