question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to perform geospatial queries

See original GitHub issue

When trying to issue a geospatial query using ‘near’ you get back an error “Can’t use $near”. I have also tried with geoNear and nearSphere as well.

Example:

var Schema = new mongoose.Schema({
    placeName: String,
    geo: {
        type: { type: String, enum: "Point", default: "Point" },
        coordinates: { type: [ Number ],   default: [ 0,0 ] }    
    }
});

somemodel.where('geo').near({ center: [50, 50] }).exec(function(err, locs){
  console.log(locs);
})

The above will return: [Error: Can’t use $near]

I have also tried the following:

model.find({
    geo: {
        $near: {
            $geometry: {
                type: "Point",
                coordinates: [50, 50]
            },
            $maxDistance: maxDistance
        }
    }
}, function(err, locs) {
    console.log(locs);
});

It will also result in the same error: [Error: Can’t use $near]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:17

github_iconTop GitHub Comments

1reaction
vkarpov15commented, Apr 23, 2016

Looks like this was just an instance of a missing query operator for single embedded subdocs, much like #4044. Will be fixed when 4.4.14 is released.

0reactions
vkarpov15commented, Apr 22, 2016

Thanks for the repro instructions @angelo0000, I’m on it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to execute queries on geospatial atributes - MongoDB
So, I have two collections using geospatial indexes, and I'm trying to execute a $near query, but MongoDB can't find the indexes.
Read more >
Unable to make geospatial query (within) with spring-boot ...
Unable to make geospatial query (within) with spring-boot, ... i've read hibernate documentation, but i'm unable to make the query works.
Read more >
Performing geospatial queries at scale | by Sander Mulders
Able to support indexing and querying geospatial shapes, in particular points, polygons and multipolygons at scale;; Able to filter based on the ...
Read more >
Azure CosmosDB MongoDB Api GeoSpatial queries not working
My understanding is that you are not able to query Geospatial data in Azure Cosmos DB MongoDB API. Geospatial queries are supported in...
Read more >
Geospatial troubleshooting - Amazon QuickSight
If Amazon QuickSight doesn't recognize your geospatial data as geospatial, use this section to help troubleshoot the issue. Make sure that your data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found