java.lang.IllegalArgumentException: Invalid BSON field name $set Doesn’t it support set operation?
Hi David,
It’s been a while since you posted your question, have you found the answer yet ?
Yes, it should still support $set
operation. You should check the content of your variable setObj
.
For example, below should work with mongo-hadoop
v2.0.2, Spark v2.0, MongoDB Java driver v3.4.x
MongoUpdateWritable test = new MongoUpdateWritable(new BasicDBObject("_id", 123),
new BasicDBObject("$set", new BasicDBObject("foo", "bar")),
true, false, false
);
And another question I found that the field name can’t contain “.”, which is inherited document use.
See also MongoDB dot-notation
I use Mongo Hadoop to store data in Spark directly.
If you’re utilising mongo-hadoop
to read/write to Spark, I would recommend to check out MongoDB Spark Connector (Java) instead. See also Spark Java Guide: Write to MongoDB
Regards,
Wan.