Class: Lucene::Field

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb,
lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb

Instance Method Summary collapse

Instance Method Details

#match(item) ⇒ Object

simple field -> value matches, supporting tailing ‘*’-wildcards in keys as well as in values



63
64
65
66
67
68
69
70
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb', line 63

def match( item )
  keys = self.elements[0].match(item)
  if keys.nil?
    false
  else
    keys.any?{ |key| self.elements[1].match(item[key]) }
  end
end

#to_arrayObject



35
36
37
38
39
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb', line 35

def to_array
  field = self.elements[0].text_value
  term = self.elements[1].to_array
  "(F:#{field} #{term})"
end

#transformObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb', line 41

def transform
  field = self.elements[0].text_value
  term = self.elements[1]
  if term.is_a? Phrase
    str = term.transform
    # remove quotes
    str = str[1 ... (str.length - 1)]
    "content:\"#{field}#{SEP}#{str}\""
  else
    "content:#{field}#{SEP}#{term.transform}"
  end
end