"isMultiKey: true" when indexing on a field containing no array

100 views
Skip to first unread message

Gheorghe

unread,
Jan 20, 2015, 9:59:05 AM1/20/15
to mongod...@googlegroups.com
Hello everyone,

I am using MongoDB under Ubuntu 12.04 and Ubuntu 14.04. I want to index my database [1] on the field "transforms.header.stamp" of type Date (not Array). When I ask MongoDB to explain my query, MongoDB answers that the field "isMultiKey" is set to "True". This should happen only when the field "transforms.header.stamp" contains an Array (which is not the case of my database). If I ask MongoDB to print the field "transforms.header.stamp" it prints no array at all.

Here is a short summary of the steps I am doing:

1. importing my database
    mongoimport --db roslog --collection tf tf.json
    connected to: 127.0.0.1
    imported 1 objects

2. building the index:
    mongo roslog --eval 'db.tf.ensureIndex( { "transforms.header.stamp" : 1 } )'
    MongoDB shell version: 2.0.4
    connecting to: roslog

3. asking my querry:
    db.tf.find( { "transforms.header.stamp": 
                      { $lt: new Date(1396512603500), 
                        $gt: new Date(1396512602000) } } ).explain(1)

4. getting the answer:
    {
    "cursor" : "BtreeCursor transforms.header.stamp_1",
    "nscanned" : 0,
    "nscannedObjects" : 0,
    "n" : 0,
    "millis" : 0,
    "nYields" : 0,
    "nChunkSkips" : 0,
    "isMultiKey" : true,
    "indexOnly" : false,
    "indexBounds" : {
        "transforms.header.stamp" : [ 
            [ 
                true
                ISODate("2014-04-03T08:10:03.500Z")
            ]
        ]
    },
    "allPlans" : [ 
        {
            "cursor" : "BtreeCursor transforms.header.stamp_1",
            "indexBounds" : {
                "transforms.header.stamp" : [ 
                    [ 
                        true
                        ISODate("2014-04-03T08:10:03.500Z")
                    ]
                ]
            }
        }
    ],
    "oldPlan" : {
        "cursor" : "BtreeCursor transforms.header.stamp_1",
        "indexBounds" : {
            "transforms.header.stamp" : [ 
                [ 
                    true
                    ISODate("2014-04-03T08:10:03.500Z")
                ]
            ]
        }
    }
}    

Could you please try to import my small database [1] and check whether you can reproduce this behavior?

Do you have an idea why this happens?

Many thanks in advance!

Cheers,
Gheorghe

[1] tf.json
tf.json

Asya Kamsky

unread,
Jan 20, 2015, 6:34:57 PM1/20/15
to mongodb-user
It appears you are using version 2.0.4 which is so old that I think
you should update to a more recent version.

Regardless of that, the field you are indexing is most certainly an
array. Here is the beginning of your single document:

{ "_id" : { "$oid" : "54b906c279f10ba2e99a8baa" },
"transforms" : [

You see the beginning of array of transforms field. You can see there
are multiple documents inside this field. Those are array elements.
You seem to have 118 of them, in fact. That's why it shows up indexed
as an array.

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/d3e47197-feb3-4742-b156-a4d91d2af454%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages