title: How to neglect fields with null value while updating Elasticsearch document?
body: <p>When i tried to update a document in elasticsearch without specifying  some fields,it updates that fields to null . Here is the code i used.</p>
  
  <pre><code>public class DocumentModel {
  @Id
  private String id;
  private Integer name;
  private String gender;
  private String url;
  private String documentID;
  ------------------
  ------------------
  getters and setters
  }
  </code></pre>
  
  <p>Code used for indexing document is :</p>
  
  <pre><code>Gson gson = new GsonBuilder().serializeNulls().create();
  String json = gson.toJson(documentModel);
  IndexRequest indexRequest = new IndexRequest(indexName, typeName, documentModel.getId());
  indexRequest.source(json);
  UpdateRequest updateRequest = new UpdateRequest(indexName, typeName, documentModel.getId());
  updateRequest.doc(json);
  updateRequest.upsert(indexRequest);
  updateRequest.fields("documentID");
  UpdateResponse updateResponse = elasticsearchTemplate.getClient().update(updateRequest).actionGet();
  </code></pre>
  
  <p>Suppose the input(documentModel) is(indexing the document first time):</p>
  
  <pre><code>{"id":1,"name":"tom","gender":"male","url":"http://www.google.com","documentID":1}
  </code></pre>
  
  <p>it will index as : </p>
  
  <pre><code>{
        "_index": "index",
        "_type": "type",
        "_id": "1",
        "_score": 1,
        "_source": {
               "name":"tom",
               "gender":"male",
               "url":"http://www.google.com",
               "documentID":1
        }
      }
  </code></pre>
  
  <p>But when i tried to update same document with input :</p>
  
  <pre><code>{"id":1,"name":"archana","gender":"female"}
  </code></pre>
  
  <p>it will update as :</p>
  
  <pre><code>{
            "_index": "index",
            "_type": "type",
            "_id": "1",
            "_score": 1,
            "_source": {
                   "name":"archana",
                   "gender":"female",
                   "url":null,
                   "documentID":null
            }
          }
  </code></pre>
  
  <p>The problem is fields that are not given as input (eg 'url','documentID') is set to null while updating document.but i want that field remains to be with the old value unless the value is not null(eg as "url":"<a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a>").</p>