SolrQuery is a ruby library designed to make building nested Solr queries simple and standardized.

It does everything for you, it deals with escaping characters, matching ActiveRecord objects by id.

It'll take an array of strings, an array of ActiveRecords.

Give it a Hash or a Range, and it'll sort out lucene range queries for you!


build a query for solr; => "Feather duster")
#=> "feather duster" => "clean", :organisation => [organisation1, organisation2])
#=> "clean AND organisation:(275 OR 6534)" => ["red", "pink"], :item_type => ["Toy", "Train"])
#=> "colour:(red OR pink) AND item_type:(Toy OR Train)"

or you can specify a different magical key for keyword;{:keyword => "old one", :new_keyword => "new one"}, :new_keyword)
#=> "new one AND keyword:(old one)"

if you need to do range queries; => {:min => "010000", :max => "050000"})
#=> "salary:([010000 TO 050000])" => "010000".."050000")
#=> "salary:([010000 TO 050000])" => {:min => "jacobs")
#=> "surname:([jacobs TO *])"

Copyright © 2008 [Matthew Rudy Jacobs], released under the MIT license