Features
Solr HTTP communication handling
Our working task list: solr-ruby/ToDo
Trying out solr-ruby
Install the solr-ruby gem gem install solr-ruby or check out solr-ruby from Subversion svn co http://svn.apache.org/repos/asf/lucene/solr/trunk/client/ruby/solr-ruby
Launch Solr: java -Dsolr.solr.home=<path to solr-ruby's solr directory> -jar start.jar
You must have Solr 1.2 already installed. This example assumes you are using the schema found under <path to solr-ruby/solr/conf directory> .
(in a separate shell) Launch irb (be sure to include the solr-ruby lib directory in your load path):
require 'solr'
# connect to the solr instance
conn = Solr::Connection.new('http://localhost:8983/solr', :autocommit => :on)
# add a document to the index
conn.add(:id => 123, :title_text => 'Lucene in Action')
# update the document
conn.update(:id => 123, :title_text => 'Solr in Action')
# print out the first hit in a query for 'action'
response = conn.query('action')
print response.hits[0]
# iterate through all the hits for 'action'
conn.query('action') do |hit|
puts hit.inspect
end
# delete document by id
conn.delete(123)
Future Development Plan
We're solr-ruby/BrainStorming DSL ideas. Join us, please.