Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17322

Different output for Mongo shell and java/python driver

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Fully Compatible
    • ALL
    • Hide

      1. Load dataset populationBefore.txt
      2. Do run findOne command. See the output . It does not looks proper output. Check the attached findOne.txt
      3. Do run FInd command like db.population.find(

      {"population.profile.name.first" : "CARROLL"}

      )

      the output is not proper.
      4. From python/java driver issue the same query db.population.find(

      {"population.profile.name.first" : "CARROLL"}

      )

      the output is different from mongoshell and not at all correct

      Strange behavior.

      5. I try with attached population.txt , load the data and works expected every where.

      Show
      1. Load dataset populationBefore.txt 2. Do run findOne command. See the output . It does not looks proper output. Check the attached findOne.txt 3. Do run FInd command like db.population.find( {"population.profile.name.first" : "CARROLL"} ) the output is not proper. 4. From python/java driver issue the same query db.population.find( {"population.profile.name.first" : "CARROLL"} ) the output is different from mongoshell and not at all correct Strange behavior. 5. I try with attached population.txt , load the data and works expected every where.

    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 ?

      Attachments

        1. findOne.txt
          8 kB
        2. population.txt
          5 kB
        3. populationBefore.txt
          5 kB

        Activity

          People

            Unassigned Unassigned
            sannandi sandip
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: