Error While writing Data into Cosmos DB (MongoDB API) – Shared throughput collection should have a partition key

I am using Apache Spark to write few (<10) JSON Documents into Cosmos DB as a Proof of Concept But I am getting this error, Does anyone know how to resolve it DB – ProductRepo Collection: Products pratitionid (shard key) – productid {“productName”: “adipisicing mollit”,”productid”: “39269afd-8139-42b8-ax2a-b46bd711392b”,”image”: “https://picsum.photos/100/100/?random”,”category”: “Shirts”,”brand”: “Silica”,”styleId”: 108897,”age”: “0-24M”} {“productName”: “zerwtfsfsfs mollit”,”productid”: “39269afd-8139-42b8-aa2a-b46bc711392b”,”image”:…

Error While writing Data into Cosmos DB (MongoDB API) – Shared throughput collection should have a partition key

I am using Apache Spark to write few (<10) JSON Documents into Cosmos DB as a Proof of Concept But I am getting this error, Does anyone know how to resolve it DB – ProductRepo Collection: Products pratitionid (shard key) – productid {“productName”: “adipisicing mollit”,”productid”: “39269afd-8139-42b8-ax2a-b46bd711392b”,”image”: “https://picsum.photos/100/100/?random”,”category”: “Shirts”,”brand”: “Silica”,”styleId”: 108897,”age”: “0-24M”} {“productName”: “zerwtfsfsfs mollit”,”productid”: “39269afd-8139-42b8-aa2a-b46bc711392b”,”image”:…

Connect java project to mongodb database

I’m trying to connect java project to my mongodb database. But I keep recieving this error although I imported the mongodb driver to the project: Exception in thread “main” java.lang.NoClassDefFoundError: com/mongodb/internal/connection/ServerAddressHelper and that’s my connection code: MongoClient mongoClient = new MongoClient(new MongoClientURI(“mongodb://localhost:27017”)); MongoDatabase database = mongoClient.getDatabase(“Etudiant”); MongoCollection collection = database.getCollection(“EtudiantC”); System.out.println(“connected!”);

How to convert a comma separated string field to array in mongodb

I have a string field in a mongodb collection which holds values in comma separated string. Now i want change the type of that particular field to array. As the collection contains 30 million records, would the below query have any performance implications? db.getCollection(“collectionName”).find().forEach( function (el) { el.NameofFieldToChangeType = el.NameofFieldToChangeType.split(‘,’); db.databaseName.save(el); });

MongoDB $in and “like” – getting records that have zip codes LIKE what is in a n array

I have a collection of addresses, with postal codes. I want to get all the records by using an array of postal codes so this query works fine db.getCollection(‘addresses’).find({“address.postal_code”:{$in:[‘40475′,’37214’]}}) This is great if all my postal codes are exactly 5 digits… But some people enter the plus 4 – so I might have an address…