Ticket #307 (closed defect: invalid)

Opened 14 years ago

Last modified 14 years ago

Index for GeoSpatial Queries (fixed report)

Reported by: tom.mcnulty@… Owned by: jaymccarthy
Priority: major Milestone:
Component: jaymccarthy/mongodb.plt Keywords:
Cc: Version: (1 7)
Racket Version: 5.0.2.1

Description

My apologies, the last report was missing the first part.

When "2d" queries are made, queries will fail if the index does not have an object id. In all cases, it seems Indexes created with racket do not have an object id.

I noticed this by comparing an index created in the shell, to one created in racket. As expected, name: doesn't seem to be important.

(mongo-collection-index! event-col (hasheq 'location '2d))
=>
{
"name" : "#hasheq((location . 2d))",
"ns" : "space.events",
"key" : {
"location" : "2d"
}
}

db.events.ensureIndex({"location" : "2d"})
=>
{
"_id" : ObjectId??("4cd4995e9edd9c1e41d8f4ba"),
"ns" : "space.events",
"key" : {
"location" : "2d"
},
"name" : "location_"
}

Change History

Changed 14 years ago by jaymccarthy

  • status changed from new to closed
  • resolution set to invalid

This is not a problem with the driver.

 http://www.mongodb.org/display/DOCS/Index-Related+Commands

states:

"> db.myCollection.ensureIndex(<keypattern>);

// same as:
db.system.indexes.insert({ name: "name", ns: "namespaceToIndex",

key: <keypattern> });"

and the implementation of mongo-collection-index! does exactly that:

(define (mongo-collection-index! c key #:name [name (generate-index-name key)])

(match-define (struct mongo-collection (db col)) c)
(define si-c (make-mongo-collection db "system.indexes"))
(mongo-collection-insert-one!

si-c
(list (cons 'name name)

(cons 'ns (mongo-collection-full-name c))
(cons 'key key))))

You should submit the report to MongoDB. In general, all other inserts create _ids, so it is strange they aren't there.

If you want a work around, you can just use mongo-db-execute-command! to run ensureIndex

Jay

Note: See TracTickets for help on using tickets.