mirror of https://github.com/apache/lucene.git
Update example to use _text field name and have explicit require/include code too, suitable for copy/pasting right into irb to work it, and cleaned up output
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@496939 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db6cbaa709
commit
59f0a1bc46
|
@ -4,21 +4,24 @@ solrb exposes the power of Solr as a Ruby DSL (domain specific language).
|
|||
|
||||
USAGE
|
||||
|
||||
First launch Solr.
|
||||
First launch Solr:
|
||||
|
||||
cd solr
|
||||
java -jar start.jar
|
||||
|
||||
In a separate shell, launch irb -Ilib.
|
||||
In a separate shell, launch {{{irb -Ilib}}}:
|
||||
|
||||
require 'solr' # load the library
|
||||
include Solr # Allow Solr:: to be omitted from class/module references
|
||||
|
||||
# connect to the solr instance
|
||||
conn = Connection.new('http://localhost:8983/solr', :autocommit => :on)
|
||||
|
||||
# add a document to the index
|
||||
conn.add(:id => 123, :title => 'Lucene in Action')
|
||||
conn.add(:id => 123, :title_text => 'Lucene in Action')
|
||||
|
||||
# update the document
|
||||
conn.update(:id => 123, :title => 'Solr in Action')
|
||||
conn.update(:id => 123, :title_text => 'Solr in Action')
|
||||
|
||||
# print out the first hit in a query for 'action'
|
||||
response = conn.query('action')
|
||||
|
@ -26,7 +29,7 @@ In a separate shell, launch irb -Ilib.
|
|||
|
||||
# iterate through all the hits for 'action'
|
||||
conn.query('action') do |hit|
|
||||
puts hit
|
||||
puts hit.inspect
|
||||
end
|
||||
|
||||
# delete document by id
|
||||
|
|
|
@ -70,6 +70,7 @@ module Solr
|
|||
# end
|
||||
|
||||
def query(query, options={}, &action)
|
||||
# TODO: Shouldn't this return an exception if the Solr status is not ok? (rather than true/false).
|
||||
options[:query] = query
|
||||
request = Solr::Request::Standard.new(options)
|
||||
response = send(request)
|
||||
|
|
Loading…
Reference in New Issue