Dear Wiki user,

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

The "Per Steffensen/Update semantics" page has been changed by Per Steffensen:
http://wiki.apache.org/solr/Per%20Steffensen/Update%20semantics?action=diff&rev1=17&rev2=18

  {{{#!java
  List<SolrInputDocument> docs = new ArrayList<SolrInputDocuments>();
  SolrInputDocument docA = new SolrInputDocument();
- ... set docA fields ...
+ //... set docA fields ...
  docA.addField(SolrInputDocument.VERSION_FIELD, -1);
  docs.add(docA);
- ... setup other docs ...
+ //... setup other docs ...
  SolrInputDocument docN = new SolrInputDocument();
- ... set docN fields ...
+ //... set docN fields ...
  docN.addField(SolrInputDocument.VERSION_FIELD, 1234567890);
  docs.add(docN);
  }}}
  
+ Note that it is not normal (as in the example above) to create a new 
SolrInputDocuments with _version_ (SolrInputDocument.VERSION_FIELD) field set 
to a number above 0 (indicating update and not insert). A SolrInputDocument 
with _version_ above 0 will usually be one that has been fetched from Solr for 
modification and restorage (update) in Solr.
  No need to deal explicitly with "part references" - SolrInputDocument will 
handle it automatically for you.
  
  ==== Sending requests ====
  
  {{{#!java
- SolrServer server = ... somehow you have a SolrJ client (instance of 
SolrServer) ...
+ SolrServer server = //... somehow you have a SolrJ client (instance of 
SolrServer) ...
  
  UpdateResponse response = server.add(docs, ... your SolrParams ...).get();
  }}}
@@ -270, +271 @@

      response = (UpdateResponse)e.getSpecializedResponse();
      DocumentUpdatePartialError err;
      err = response.getPartialError(docA);
-     ... if and only if err is not null the insert/update of docA failed ...
+     //... if and only if err is not null the insert/update of docA failed ...
-     ... check for errors for other docs ...
+     //... check for errors for other docs ...
      err = response.getPartialError(docN);
-     ... if and only if err is not null the insert/update of docN failed ...
+     //... if and only if err is not null the insert/update of docN failed ...
  }
  }}}
  
@@ -285, +286 @@

  try {
      UpdateResponse response = server.add(... one doc ..., ... your SolrParams 
...).get();
  } catch (org.apache.solr.common.partialerrors.update.DocumentDoesNotExist e) {
-     ... do something ...
+     //... do something ...
  } catch (org.apache.solr.common.partialerrors.update.DocumentAlreadyExists e) 
{
-     ... do something ...
+     //... do something ...
  } catch (org.apache.solr.common.partialerrors.update.VersionConflict e) {
-     ... do something ...
+     //... do something ...
  } catch (org.apache.solr.common.partialerrors.WrongUsage e) {
-     ... do something ...
+     //... do something ...
  }
  }}}
  

Reply via email to