Class: StreamingUpdateSolrServer
- Inherits:
-
Object
- Object
- StreamingUpdateSolrServer
- Defined in:
- lib/jruby_streaming_update_solr_server.rb
Overview
Sugar on top of the org.apache.solr.client.solr.impl.StreamingUpdateSolrServer
Note that several important methods, new and commit, are direct from the java and hence not represented here where I’m just opening up the class to add some sugar. Full documentation for the raw java methods is available at lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html
A quick look at important java methods you can call:
suss = StreamingUpdateSolrServer.new(solrURL, queueSize, numberOfThreads)
The constructor.
[String] solrURL The URL to your solr instance (i.e., http://solr-machine:port/solr)
[Integer] queueSize The size of the queue from which consumer threads will pull
documents ready to be added to Solr and actually do the sending.
[Integer] numberOfThreads The number of consumer threads to do the sending-to-Solr
suss.commit
Send the commit to the solr server
suss.optimize
Send the optimize commnd to the Solr server
suss.deleteById(id)
suss.deleteById([id1, id2, id3, …])
Delete the given ID or IDs
suss.deleteByQuery(query)
Delete everything that matches +query+
[String] query A valid solr query. Everything that matches will be deleted. So, you can ditch
it all by sending, e.g., '*:*'
Instance Method Summary collapse
-
#add(doc) ⇒ Object
(also: #<<)
Add a document to the SUSS that responds to #each_pair) to add.
-
#sussadd ⇒ Object
Hang onto the java #add for internal use.
-
#useJavabin! ⇒ Object
Send requests using the Javabin binary format instead of serializing to XML Requires /update/javabin to be defined in solrconfig.xml as <requestHandler name=“/update/javabin” class=“solr.BinaryUpdateRequestHandler” />.
Instance Method Details
#add(doc) ⇒ Object Also known as: <<
Add a document to the SUSS that responds to #each_pair) to add. The latter must be of the form solrfield => value or solrfield => [list, of, values]. They keys must be strings.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/jruby_streaming_update_solr_server.rb', line 96 def add doc if doc.is_a? org.apache.solr.common.SolrInputDocument sussadd doc elsif doc.respond_to? :each_pair newdoc = SolrInputDocument.new doc.each_pair do |f,v| newdoc << [f,v] end sussadd newdoc else raise ArgumentError "Need to pass either an org.apache.solr.common.SolrInputDocument or a hash" end end |
#sussadd ⇒ Object
Hang onto the java #add for internal use
65 |
# File 'lib/jruby_streaming_update_solr_server.rb', line 65 alias_method :sussadd, :add |
#useJavabin! ⇒ Object
Send requests using the Javabin binary format instead of serializing to XML Requires /update/javabin to be defined in solrconfig.xml as <requestHandler name=“/update/javabin” class=“solr.BinaryUpdateRequestHandler” />
58 59 60 |
# File 'lib/jruby_streaming_update_solr_server.rb', line 58 def useJavabin! self.setRequestWriter Java::org.apache.solr.client.solrj.impl.BinaryRequestWriter.new end |