[mongodb-user] slice issue

20 views
Skip to first unread message

Crudson

unread,
May 4, 2010, 12:05:41 PM5/4/10
to mongodb-user
I am very excited about the new slice function, but I am experiencing
some unexpected results. I am slicing on an array of two element
arrays of [string, int].

Here is a typical document:
> db.author_mesh_heading_count.findOne()
{
"_id" : ObjectId("4bdf0dee495b2636d467aaa4"),
"headings" : [
[
"Food Preservation",
1
],
[
"Hot Temperature",
1
],
[
"Food Microbiology",
1
],
[
"Animals",
1
],
[
"Spores",
1
],
[
"Milk",
1
],
[
"Buffers",
1
],
[
"Bacillus subtilis",
1
]
],
"author" : "aalbersberg wi"
}

Asking for the first is only returning the string:
> db.author_mesh_heading_count.findOne({}, { headings: { $slice: 1 } })
{
"_id" : ObjectId("4bdf0dee495b2636d467aaa4"),
"headings" : [
[
"Food Preservation"
]
],
"author" : "aalbersberg wi"
}

Asking for the first two is correctly returning the string and the
int:
> db.author_mesh_heading_count.findOne({}, { headings: { $slice: 2 } })
{
"_id" : ObjectId("4bdf0dee495b2636d467aaa4"),
"headings" : [
[
"Food Preservation",
1
],
[
"Hot Temperature",
1
]
],
"author" : "aalbersberg wi"
}

Skip one, return two is only returning the int (or 1 from somewhere
else):
> db.author_mesh_heading_count.findOne({}, { headings: { $slice: [1,2] } })
{
"_id" : ObjectId("4bdf0dee495b2636d467aaa4"),
"headings" : [
[
1
],
[
1
]
],
"author" : "aalbersberg wi"
}

Skip three, return one is not giving anything:
> db.author_mesh_heading_count.findOne({}, { headings: { $slice: [3,1] } })
{
"_id" : ObjectId("4bdf0dee495b2636d467aaa4"),
"headings" : [
[ ]
],
"author" : "aalbersberg wi"
}

Am I missing something? I would have expected elements of the sliced
array to be untouched.

Tue May 4 11:44:20 db version v1.5.1-pre-, pdfile version 4.5
Tue May 4 11:44:20 git version:
8df6518e62d98201aa281dc500d28f9901228283
Tue May 4 11:44:20 sys info: Linux domU-12-31-39-06-79-A1
2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64
BOOST_LIB_VERSION=1_41

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Crudson

unread,
May 4, 2010, 12:35:02 PM5/4/10
to mongodb-user
uname -a
2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64
GNU/Linux

Mathias Stearn

unread,
May 4, 2010, 12:46:39 PM5/4/10
to mongod...@googlegroups.com
This is probably a bug with handling nested arrays. Could you open a jira case?

Crudson

unread,
May 4, 2010, 1:54:32 PM5/4/10
to mongodb-user
Ticket created: http://jira.mongodb.org/browse/SERVER-1085

On May 4, 12:46 pm, Mathias Stearn <math...@10gen.com> wrote:
> This is probably a bug with handling nested arrays. Could you open a jira case?
>
> On Tue, May 4, 2010 at 12:35 PM, Crudson <crud...@gmail.com> wrote:
> > uname -a
> > 2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64
> > GNU/Linux
>
> > --
> > You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
Reply all
Reply to author
Forward
0 new messages