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.