MongoDB Math functions like $mod accept NumberLong in mongo shell but not through Java driver -


this sample record in collection "compliance":

{     "_id" : "fc750415-9425-413c-906d-0c15e1628b0d",     "gcid" : "e9c5c788-a8df-4080-a94f-7949fc17bfa0",     "audittime" : numberlong("1437316807198"),     "auditmonth" : numberlong("1427826600000"),     "checksum" : "30e4ae5aa93cfb17ad9876df6feea17149a0f347",     "policyids" : [         "be0edaa7-6972-4397-8c0b-e8cceec5b929"     ],     "rectype" : "processed",     "starttime" : numberlong("1437316807198"),     "transid" : "-1",     "transtime" : numberlong("1437316807198") } 

here mongodb query give me count of records "audittime" field boundaries of 100 milliseconds:

db.compliance.aggregate([              {$project:                     {                     id: 1,                     rectype: 1,                     audittime: 1,                      auditday: { $subtract: ["$audittime", { $mod: ["$audittime", 100]}]}                    }              }              {$match:                  {                  rectype:"assigned",                   audittime:{$lte:numberlong("1437141242748"), $gte:numberlong("1437139368604")}                 }              },              {$group:                 {                  _id: "$auditday",                  count : {$sum:1}                 }              }             ]                ) 

this works in mongo shell, when construct same query using java driver (version 2.10), gives me following error:

command failed [aggregate]: { "serverused" : "localhost/127.0.0.1:27018" , "errmsg" : "exception: $mod supports numeric types, not numberlong64 , string" , "code" : 16611 , "ok" : 0.0 , "$glestats" : { "lastoptime" : { "$ts" : 1437488274 , "$inc" : 1} , "electionid" : { "$oid" : "55acc0fada2f10f0d6c7e6c1"}}} 

why java driver refuse take long values arithmetic functions while mongo shell accepts? there way convert numberlong values numeric types without updating record? there alternative way of writing query using java driver?


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -