title: Updating a document in Solr using SolrJ
body: <p>I have following indexed data in Solr. I want to add an extra field "Location" in this indexed data using SolrJ. How can I do this?</p>
  
  <pre><code>"response":{"numFound":3061,"start":3059,"docs":[
        {
          "Id":12345,
          "Name":"Rajeev Kumar",
          "_version_":1223434645768768687},
        {
          "Id":67890,
          "Name":"Rohit Kumar",
          "_version_":1246457656544545434}]
    }}
  </code></pre>
  
  <p>After updating it should look like this - </p>
  
  <pre><code>"response":{"numFound":3061,"start":3059,"docs":[
        {
          "Id":12345,
          "Name":"Rajeev Kumar",
          "Location" : &lt;some value&gt;,
          "_version_":1223434645768768687},
        {
          "Id":67890,
          "Name":"Rohit Kumar",
          "Location": &lt;some value&gt;,
          "_version_":1246457656544545434}]
    }}
  </code></pre>
  
  <p>I tried something like this - </p>
  
  <pre><code>  public static void main(String[] args) throws SolrServerException, IOException {
  
              String urlString = "http://localhost:8983/solr/gettingstarted";
              HttpSolrClient solr = new HttpSolrClient.Builder(urlString).build();
              solr.setParser(new XMLResponseParser());
              SolrInputDocument document = new SolrInputDocument();
              HashMap&lt;String, Object&gt; value = new HashMap&lt;String, Object&gt;(); 
              value.put("set","Delhi"); 
              document.addField("Location", value); 
               solr.commit();
      }
  </code></pre>
  
  <p>But the problem is that this is creating a new document instead of updating the old document. Thanks for help in advance.</p>