DelSolr – Simplifying Solr Facets in Ruby

Get Version



delsolr is a light weight ruby wrapper for Solr. Its goal is to
preserve all the power of the Solr webservice while keeping the interface as simple and ruby-esque as possible.


sudo gem install delsolr

Demonstration of usage

See the rdoc for full documentation. Also, check out ruby-on-the-interrails for updates, news, tricks, etc…

c = => 'solr1', :port => 8983)
rsp = c.query('dismax',
               :query => 'mp3 player',
               :filters => {:cost => (50..100)},
               :facets => [{:field => 'brand', :limit => 10},
                           {:query => {:onsale => true, :brand => 'Apple'},
                            :name => 'cheap_apple'}])

# output total matches

# output each id with score { |doc| puts "#{doc[:id]} - #{doc[:score]}" }

# output each value for a facet
rsp.facet_field_values('brand').each do |brand|
  puts "#{brand}: #{rsp.facet_field_count('brand', brand}"

# output a query facet
puts "Cheap Apple stuff: #{rsp.facet_query_count_by_name('cheap_apple')}"

# adding things
doc =
doc.add_field('id', 'ABC-123')
doc.add_field('name', '8 Gig Shuffle')
doc.add_field('description', 'A crazy-tiny MP3 player')
c.update!(doc) # posts new document to solr
c.commit! # posts a commit to solr

rsp = c.query('dismax', :query => 'shuffle mp3 player')
puts rsp.ids[0]


How to submit patches

You can fetch the source from github:

Or you can submit diffs via the google group and they may or may not make it in.

How to report bugs

Please use the tracker on rubyforge

Build and test instructions

cd delsolr
rake test
rake install_gem


This code is free to use under the terms of the MIT license.


Comments are welcome. Send an email to Ben VandenBos email via the google group

find a lawyer
Theme extended from Paul Battley