title: Spring Boot not able to update sharded collection on azure cosmos db(MongoDb)
body: <p>I have a collection "documentDev" present in the database with sharding key as 'dNumber' 
  Sample Document :</p>
  
  <pre><code>{
  "_id" : "12831221wadaee23",
  "dNumber" : "115",
  "processed": false
  }
  </code></pre>
  
  <p>If I try to update this document through any query tool using a command like - </p>
  
  <pre><code>db.documentDev.update({
    "_id" : ObjectId("12831221wadaee23"),
    "dNumber":"115"
  },{
      $set:{"processed": true}}, 
  { multi: false, upsert: false}
  )}`
  </code></pre>
  
  <p>It updates the document properly. 
  But if I do use spring boot's mongorepository command like
      DocumentRepo.save(Object) 
  it throws an exception </p>
  
  <blockquote>
    <ul>
    <li>Caused by: com.mongodb.MongoCommandException: Command failed with error 61: 'query in command must target a single shard key' on server by3prdddc01-docdb-3.documents.azure.com:10255. The full response is { "_t" : "OKMongoResponse", "ok" : 0, "code" : 61, "errmsg" : "query in command must target a single shard key", "$err" : "query in command must target a single shard key" }</li>
    </ul>
  </blockquote>
  
  <p>This is my DocumentObject:</p>
  
  <pre><code>@Document(collection = "documentDev")
  public class DocumentDev
  {
  @Id
  private String id;
  private String dNumber;
  private String fileName;
  private boolean processed;
  }
  </code></pre>
  
  <p>This is my Repository Class -</p>
  
  <pre><code>@Repository
  public interface DocumentRepo extends MongoRepository&lt;DocumentDev, 
  String&gt; { }
  </code></pre>
  
  <p>and value i am trying to update</p>
  
  <blockquote>
    <ul>
    <li>Value : doc : 
    {
    "_id" : "12831221wadaee23",
    "dNumber" : "115",
    "processed": true
    }  </li>
    </ul>
  </blockquote>
  
  <p>the function I am trying to execute :</p>
  
  <pre><code>@Autowired
  DocumentRepo docRepo;
  
  docRepo.save(doc); // Fails to execute
  </code></pre>
  
  <p>Note: I have sharding enabled on dNumber field. And I am successfully able to update using Native queries on NoSQL Tool.
  I was also able to execute the Repository save operation on Non sharded collection.</p>
  
  <p>Update: I am able to update the document by creating native query using MongoTemplate - My Query looks like this -</p>
  
  <pre><code>public DocumentDev updateProcessedFlag(DocumentDev request) {
      Query query = new Query();
      query.addCriteria(Criteria.where("_id").is(request.getId()));
      query.addCriteria(Criteria.where("dNumber").is(request.getDNumber()));
      Update update = new Update();
      update.set("processed", request.isProcessed());
      mongoTemplate.updateFirst(query, update, request.getClass());
      return request;
  }
  </code></pre>
  
  <p>But this is not a generic solution as any other field might have update and my document may have other fields as well.</p>