You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2009/04/09 08:15:15 UTC

[Solr Wiki] Update of "Solrj" by NoblePaul

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The following page has been changed by NoblePaul:
http://wiki.apache.org/solr/Solrj

The comment on the change is:
added batch update

------------------------------------------------------------------------------
    req.add( docs );
    UpdateResponse rsp = req.process( server );  
  }}}
+ 
+ === Streaming documents for an update ===
+ <!> ["Solr1.4"]
+ 
+ This is the most optimal way of updating all your docs in one http request.
+ {{{
+ CommonsHttpSolrServer server = new CommonsHttpSolrServer();
+ Iterator<SolrInputDocument> iter = new Iterator<SolrInputDocument>(){
+      public boolean hasNext() {
+         boolean result ;
+         // set the result to true false to say if you have more documensts
+         return result;
+       }
+ 
+       public SolrInputDocument next() {
+         SolrInputDocument result = null;
+         // construct a new document here and set it to result
+         return result;;
+       }
+ };
+ server.add(iter);
+ }}}
+ 
+ you may also use the `addBeans(Iterator<?> beansIter)` method to write pojos 
  [[Anchor(pojo)]]
  
  === Directly adding POJOs to Solr ===