Class: MultiSolr::SolrFilterDateRange

Inherits:
SolrFilterRange show all
Defined in:
lib/multi_solr/solr_filter_date_range.rb

Overview

Filter für Datumsbereiche mit von- und bis-Datum

Instance Attribute Summary

Attributes inherited from SolrFilterSimple

#field_name, #name, #options

Instance Method Summary collapse

Methods inherited from SolrFilterRange

#extract_from_to, #render_value

Methods inherited from SolrFilterSimple

#initialize, #label, #render_value, #sanitize_value

Constructor Details

This class inherits a constructor from MultiSolr::SolrFilterSimple

Instance Method Details

#build_solr_query(value) ⇒ Object

Erzeugen des SolR-Query-Strings



6
7
8
9
10
# File 'lib/multi_solr/solr_filter_date_range.rb', line 6

def build_solr_query value
  from, to = extract_from_to_in_ISO8601 value
  return nil if from.nil? && to.nil?
  "#{@field_name}:[#{from || '*'} TO #{to || '*'}]"
end

#extract_from_to_in_ISO8601(value) ⇒ Object



14
15
16
17
18
19
# File 'lib/multi_solr/solr_filter_date_range.rb', line 14

def extract_from_to_in_ISO8601 value
  from, to = extract_from_to value
  d_from = from.blank? ? nil : "#{from}T00:00:00Z"
  d_to = to.blank? ? nil : "#{to}T23:59:59Z"
  [d_from, d_to]
end