Note that there are some explanatory texts on larger screens.

plurals
  1. POSolr, how to use the new field update modes (atomic updates) with SolrJ
    primarykey
    data
    text
    <p>Solr 4.x has this nice new feature that lets you specify how, when doing an update on an existing document, the multiValued fields will be updated. Specifically, you can say if the update document will replace the old values of a multivalued field with the new ones, or if it should append the new values to the existing ones.</p> <p>I've tried this using the request handler, as described here:</p> <p><a href="http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22" rel="nofollow">http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22</a></p> <p>I've used curl to send xml where some fields used the <code>update=add</code> option:</p> <pre><code>&lt;field name="skills" update="add"&gt;Python&lt;/field&gt; </code></pre> <p>This works as expected.</p> <p>However I can't get how to do this the Java API (SolrJ). </p> <p>If I do something like this:</p> <pre><code>SolrInputDocument doc1 = new SolrInputDocument(); doc1.setField("ID_VENTE", "idv1"); doc1.setField("FACTURES_PRODUIT", "fp_initial"); solrServer.add(doc1); solrServer.commit(); SolrInputDocument doc2 = new SolrInputDocument(); doc2.setField("ID_VENTE", "idv1"); doc2.setField("FACTURES_PRODUIT", "fp_2"); solrServer.add(doc2); solrServer.commit(); </code></pre> <p>The value for the field "FACTURES_PRODUIT" becomes "fp_2" (the initial value is lost). I've also tried:</p> <pre><code>doc2.addField("FACTURES_PRODUIT", "fp_2"); </code></pre> <p>but the result is the same. I've also looked into the <a href="https://builds.apache.org/job/Solr-Artifacts-4.x/javadoc/solr-solrj/org/apache/solr/common/SolrInputField.html" rel="nofollow">SolrInputField</a> class but haven't found anything similar to this.</p> <p>So, my question is, how can I use the Solr 4 Java API to updated values into a multiValued field by appening (not replacing) the new values?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload