I am querying MongoDB with Spark using Stratio (0.11.). I am interested to use RDDs (no DataFrame).
What I am doing right now is:
val mongoRDD = new MongodbRDD(sqlContext, readConfig, new MongodbPartitioner(readConfig))
mongoRDD.foreach(println)
and it displays the collection content in a correct way.
Is there a way to use a query (as String or built via QueryBuilder) with Stratio (in my case the query is $near type) to apply to MongodbRDD?
As @zero323 has hinted, the way to do that is using
filtersparameter. These filters are checked by the library and matched against the MongoDB QueryBuilder available filters.From Spark-MongoDB source code:
As you can see,
nearis not being applied but it seems like it could be easily added to the connector functionality sinceQueryBuilderoffers methods to use that MongoDB function.You can try to modify the connector. However I'll try to implement it and make a PR in the following days.
EDIT:
A PR has been opened including a source filter type which describes
$nearso you can useMongodbRddas: