2007-01-02 23:57:00 -05:00
|
|
|
solrb exposes the power of Solr as a Ruby DSL (domain specific language).
|
|
|
|
|
2007-01-14 21:43:02 -05:00
|
|
|
Visit the solrb wiki for more information: http://wiki.apache.org/solr/solrb
|
2007-01-02 23:57:00 -05:00
|
|
|
|
|
|
|
USAGE
|
|
|
|
|
|
|
|
First launch Solr.
|
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
cd solr
|
|
|
|
java -jar start.jar
|
2007-01-14 21:43:02 -05:00
|
|
|
|
|
|
|
In a separate shell, launch irb -Ilib.
|
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# connect to the solr instance
|
|
|
|
conn = Connection.new('http://localhost:8983/solr')
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# add a document to the index
|
|
|
|
conn.add(:id => 123, :title => 'Lucene in Action')
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# update the document
|
|
|
|
conn.update(:id => 123, :title => 'Solr in Action')
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# print out the first hit in a query for 'action'
|
|
|
|
response = conn.query('action')
|
|
|
|
print response.hits[0]
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# iterate through all the hits for 'action'
|
|
|
|
conn.query('action') do |hit|
|
|
|
|
puts hit
|
|
|
|
end
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-16 17:02:29 -05:00
|
|
|
# delete document by id
|
|
|
|
conn.delete(123)
|
2007-01-02 23:57:00 -05:00
|
|
|
|
|
|
|
INSTALLATION
|
|
|
|
|
|
|
|
First run the tests:
|
|
|
|
|
2007-01-14 21:43:02 -05:00
|
|
|
rake
|
|
|
|
|
2007-01-02 23:57:00 -05:00
|
|
|
then build the gem:
|
|
|
|
|
|
|
|
rake package
|
|
|
|
|
|
|
|
and install the versioned gem:
|
|
|
|
|
|
|
|
gem install pkg/solr-x.x.x.gem
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
|
|
|
|
This package is licensed using the Apache Software License 2.0.
|
|
|
|
|
|
|
|
<http://www.apache.org/licenses/LICENSE-2.0>
|