+1 On Sun, Dec 20, 2015 at 10:28 PM, Debraj Manna <subharaj.ma...@gmail.com> wrote:
> Thanks Andrea for the detailed explanation. > On Dec 19, 2015 1:34 PM, "Andrea Gazzarini" <a.gazzar...@gmail.com> wrote: > > > That has nothing to do with your topic: addField adds a new value for a > > given field in a SolrInputDocument, while setField replaces any existing > > value (of a given field, regardless what is the existing value, I mean, > > regardless if that field has zero, one or more values). > > > > SolrInputDocument document = new SolrInputDocument(); > > > > document.set("id", 32872382); // the id field has now one value: > 32872382 > > > > document.add("author", "B. Meyer") // the author field has one value. In > > this case, being the first value, add() and set() behave in the the same > > way > > > > document.add("author", "A. Yersu") // Now the author field has two values > > document.set("author", "I.UUhash") // That will replace the existing two > > values with this value. > > > > > > solrClient.add(document); // here, You are sending document with 1 id > and > > 1 author > > > > > > > > Those are methods of SolrInputDocument; when you call them, you're > changing > > the state of a local transfer object (the SolrInputDocument instance). > > Before sending that to Solr using solrClient.add(SolrInputDocument) you > can > > do whatever you want with that instance (i.e. removing, adding, setting > > values). The "document" representation that Solr will see is the state of > > the instance that you pass to solrClient.add(...) > > > > Best, > > Andrea > > > > > > 2015-12-19 8:48 GMT+01:00 Debraj Manna <subharaj.ma...@gmail.com>: > > > > > Ok. Then what is the difference between addField > > > < > > > > > > http://github.com/apache/lucene-solr/tree/lucene_solr_5_3_1/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java#L150 > > > > > > > & setField > > > < > > > > > > http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/common/SolrInputDocument.html#setField-java.lang.String-java.lang.Object-float- > > > > > > > ? > > > > > > On Sat, Dec 19, 2015 at 1:04 PM, Andrea Gazzarini < > a.gazzar...@gmail.com > > > > > > wrote: > > > > > > > As far as I know, this is how Solr works (e.g. it replaces the whole > > > > document): how do you replace only a part of a document? > > > > > > > > Just send a SolrInputDocument with an existing (i.e. already indexed) > > id > > > > and the document (on Solr) will be replaced. > > > > > > > > Andrea > > > > > > > > 2015-12-19 8:16 GMT+01:00 Debraj Manna <subharaj.ma...@gmail.com>: > > > > > > > > > Can someone let me know how can I replace a document on each update > > in > > > > Solr > > > > > 5.2.1 using SolrJ? I don;t want to update parts of the document. On > > > doing > > > > > update it should replace the entire document. > > > > > > > > > > > > > > > -- Ph: 9845704792