我正在研究一个火花代码,其中我使用MongoSpark连接器https://docs.mongodb.com/spark-connector/master/java/write-to-mongodb/
创建地理空间对象类型JavaRDD<Document> document = ds
.toJavaRDD()
.map(f -> {
Document doc = new Document();
/***************/
List<Double> practice_Cordinates = new ArrayList<Double>();
practice_Cordinates.add(0.0); // Long
practice_Cordinates.add(0.0); // Lat
BasicDBObject GeoSpatial_Obj = new BasicDBObject("type", "Point").
append("coordinates", practice_Cordinates);
/***************/
doc.put("GeoSpatial", GeoSpatial_Obj);
return doc;
});
MongoSpark.save(document);
"GeoSpatial" : {
"coordinates" : [
-73.881631,
40.880462
],
"type" : "Point"
},
现在在推送数百万条记录之后,我是否需要使用典型的mongo-java代码通过在Java中提供以下代码来获取集合并更新索引
火花代码-MongoSpark.save(DS)之后
MongoClient mongoClient = new MongoClient();
DBCollection test = mongoClient.getDB("testdb").getCollection("test");
test.createIndex(new BasicDBObject("GeoSpatial","2dsphere"));
MongoSpark 驱动程序是否具有内置方法来处理此createindex,ensureindex吗?