jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
286 stars 64 forks source link

Query Issue with Aggregation #93

Open koushiksaha89 opened 7 years ago

koushiksaha89 commented 7 years ago

Same query in mongo shell returns results but with mongolite i'm getting zero documents. Below is the query mon$aggregate('[{"$group":{"_id":{"Source":"$SourceId","Destination":"$DestinationId"},"Count":{"$sum":1}}},{"$sort":{"Count":-1}}]')

Am i doing anything wrong?

JeremyBesson commented 7 years ago

Hi,

I had the same issue when I tried to use it. I think this isn't from a mongolite issue but from jsonlite when you use mongo aggregate mongo return a JSON texte with a table like:

[{"Source": 1, "Destination":2, "Count":3}, {"Sou... }]

And fromJSON function in jsonlite package don't now how to convert that into a dataframe, so you get nothing.

JeremyBesson commented 7 years ago

Someone already open the jsonlite issue here : https://github.com/jeroen/jsonlite/issues/192