Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
Fully Compatible
-
ALL
-
Description
I have a data set , which I have attached . Now with this dataset mongodb behavior is unpredictable . I am very interested to know the reason.
Let?s for example , I load the data into mongodb :
mongoimport --db test --collection population --file populationBefore.txt --type json --jsonArray
Now when I do findOne query on this data the result is not expected. I have attached the file named findOne.txt , where you will find all JSON sub documents are same . Any reason why ?
Query within find
From pymongo module / mongojava I have tried this . When I tried the following query , result is something different
>>> post=collection.find({"population.profile.name.first" : "CARROLL"})
|
>>> for p in post:
|
... print p
|
...
|
{u'_id': ObjectId('54878c84062dfda18bcb487d'), u'population': {u'profile': {u'networth': u'428737827.60', u'siblings': u'9', u'birthday': u'1879-07-02', u'name': {u'@sex': u'f', u'last': u'SHANK', u'MI': u'P', u'first': u'AURELIO'}, u'address': {u'city': u'River Oaks ', u'zip': u'94117', u'addnum': u'1845', u'state': u'NM', u'street': u'13th Avenue ', u'@type': u'duplex'}}}}
|
In the result you can see no CARROLL is found .
? Same Query from Mongodb.
If I use same query with mongodb , the result is completely different . The returned document replaced all entry with NAME CARROLL and returned. While we have only one entry with name CARROLL. You will find so many CARROLL here.
mongos> db.population.find({"population.profile.name.first" : "CARROLL"})
|
{ "_id" : ObjectId("54dcf22100894990c1851e31"), "population" : { "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" }, "profile" : { "name" : { "@sex" : "m", "first" : "CARROLL", "MI" : "R", "last" : "DENNEY" }, "birthday" : "2010-04-05", "address" : { "@type" : "duplex", "addnum" : "45454", "street" : "Skidmore Lane ", "city" : "Center City ", "state" : "UT", "zip" : "15965" }, "siblings" : "5", "networth" : "-129768966.39" } } }
|
mongos>
|
Bothe JAVA/PYTHON driver returns different result set from mongodb .
I am very interested to know why is this behavior ? How mongodb treating things differently from java/python driver ? How mongodb stored multiple JSON object with same key ?