Class: Lucene::FieldRange

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/chef/solr_query/lucene_nodes.rb

Direct Known Subclasses

ExclFieldRange, InclFieldRange

Instance Method Summary collapse

Instance Method Details

#to_arrayObject



57
58
59
60
61
62
# File 'lib/chef/solr_query/lucene_nodes.rb', line 57

def to_array
  field = self.elements[0].text_value
  range_start = self.elements[1].to_array
  range_end = self.elements[2].to_array
  "(FR:#{field} #{left}#{range_start}#{right} #{left}#{range_end}#{right})"
end

#transformObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/chef/solr_query/lucene_nodes.rb', line 64

def transform
  field = self.elements[0].text_value
  range_start = self.elements[1].transform
  range_end = self.elements[2].transform
  # FIXME: handle special cases for missing start/end
  if ("*" == range_start && "*" == range_end)
    "content:#{field}#{SEP}*"
  elsif "*" == range_end
    "content:#{left}#{field}#{SEP}#{range_start} TO #{field}#{SEP}\\ufff0#{right}"
  elsif "*" == range_start
    "content:#{left}#{field}#{SEP} TO #{field}#{SEP}#{range_end}#{right}"
  else
    "content:#{left}#{field}#{SEP}#{range_start} TO #{field}#{SEP}#{range_end}#{right}"
  end
end