简体   繁体   中英

How to query objects with points in fields in mongodb

How do I query to find a register like find where X2016.may = 32863. My solution work for geting the 'RFC' register.

db.getCollection('collection').find({"RFC" : "AAA020211GV8"})

But it doesn't work for querying the other data, does not find any records and returns:

db.getCollection('input').find({"X2016.may" : 32863})
"Fetched 0 record(s) in 14ms"

This is a sample document.

{
    "_id" : ObjectId("5756f39de030aeae54a72b6a"),
    "RFC" : "AAA020211GV8",
    "X2016.may" : 32863,
    "X2016.abr" : 34071,
    "X2016.mar" : 23793,
    "X2016.feb" : 86647,
    "X2016.ene" : 30864,
    "X2015.dic" : 84694,
    "X2015.nov" : 80124,
    "X2015.oct" : 97883,
    "X2015.sep" : 29913,
    "X2015.ago" : 57526,
    "X2015.jul" : 82927,
    "X2015.jun" : 34261,
    "X2015.may" : 98638,
    "X2015.abr" : 64738,
    "X2015.mar" : 45826,
    "X2015.feb" : 78345,
    "X2015.ene" : 75287,
    "X2014.dic" : 46050,
    "X2014.nov" : 86394,
    "X2014.oct" : 54328,
    "X2014.sep" : 65698,
    "X2014.ago" : 68757,
    "X2014.jul" : 30403,
    "X2014.jun" : 43622
}

Thanks!

The solution was to substitute the "." for a "_" with the next function before making the mmongo.insert.batch() to uploading the data to mongo.

names(df) <- gsub(" ", "_", names(df))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM