Skip to content

Instantly share code, notes, and snippets.

@gatesvp
Created April 7, 2011 19:45
Show Gist options
  • Select an option

  • Save gatesvp/908554 to your computer and use it in GitHub Desktop.

Select an option

Save gatesvp/908554 to your computer and use it in GitHub Desktop.
test distinct + geo index
> db.locations.insert({coords: [-79.4434, 44.1428], type: 'bank', tags:['24h', 'finance']})
> db.locations.insert({coords: [-62.0343, 45.4432], type: 'cinema', tags: ['film', 'popcorn']})
> db.locations.insert({coords: [-64.3433, 45.3341], type: 'cafe', tags: ['coffee', 'tea']})
> db.locations.distinct('type')
[ "bank", "cinema", "cafe" ]
> db.locations.ensureIndex({ type : 1 })
> db.locations.distinct('type')
[ "bank", "cafe", "cinema" ]
> db.locations.ensureIndex({coords: '2d', type: 1, tags: 1})
> db.locations.distinct('type')
[ "bank", "cafe", "cinema" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment