Class: Query
- Inherits:
-
Object
- Object
- Query
- Defined in:
- lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb
Constant Summary collapse
- @@grammar =
initialize the parser by using the grammar shipped with chef
File.join(Chef::SolrQuery::QueryTransform.base_path, "lucene.treetop")
- @@parser =
LuceneParser.new
Class Method Summary collapse
Class Method Details
.parse(data) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb', line 195 def self.parse(data) # parse the query into a query tree if data.nil? data = "*:*" end tree = @@parser.parse(data) if tree.nil? msg = "Parse error at offset: #{@@parser.index}\n" msg += "Reason: #{@@parser.failure_reason}" raise "Query #{data} is not supported: #{msg}" end self.clean_tree(tree) tree end |