Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:28:58+00:00 2026-06-13T20:28:58+00:00

I want to query against a geospatial index in mongo-db (designed after this tutorial

  • 0

I want to query against a geospatial index in mongo-db (designed after this tutorial http://www.mongodb.org/display/DOCS/Geospatial+Indexing).

So when I execute this from the shell everything works fine:

db.sellingpoints.find(( { location : { $near: [48.190120, 16.270895], $maxDistance: 7 / 111.2 } } );

but the same query from my nodejs application (using mongoskin or mongoose), won’t return any results until i set the distance-value to a very high number (5690)

db.collection('sellingpoints')
 .find({ location: { $near: [lat,lng], $maxDistance: distance / 111.2} })
 .limit(limit)
 .toArray(callback);

Has someone any idea how to fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:29:00+00:00Added an answer on June 13, 2026 at 8:29 pm

    I just tried a simple node mongoose script against some geo localized data. I’m using the cities geo data from http://dev.maxmind.com/geoip/geolite, loading it all into mongodb.
    I’ve wrote a small test code for this (https://github.com/nleite/mongoose_test).

    var mongoose = require('mongoose');
    var db = mongoose.createConnection( 'localhost', 'geo');
    
    var schema = mongoose.Schema( { city: 'string', loc: 'array', areaCode: 'string', country:      'string', region: 'string', locId: 'string', metroCode: 'string', postalCode: 'string'} );
    
    var City = db.model( 'City', schema);
    var distance = 7 / 111.2;
    console.log( 'Distance %s', distance);
    var query = City.find( { 'loc':  { $near: [48.190120, 16.270895], $maxDistance: distance      }} ); 
    query.exec( function( err, city){
       if (err) return handleError(err);
       console.log( 'Found you %s' , city);
       process.exit(-1);
    }); 
    

    It seems to be working pretty well. I’ve even took your query to check if there could be any problem with it, but seems to be working fine.

    Can you please give as more info on the Schema and the Query that is not working as you expected ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem. I want to use a LINQ query against this database:
I want to fetch google images against any query. I have gone through the
I want to run an update query. The query will be run against multiple
I want DBSession.query(Article).group_by(Article.created.month).all() But this query can't using How do I do this using
I want to run an update query against a production database and as good
Summary: I want to be able to run a query against an external database
Using the c# driver for MongoDB I can easily construct a query against which
I have this simple code to query against the web service:- $.get( url ,
I want to query my table against two dates and retrieve the records within
I'm using Postgresql DB. I want to perform a query against a numeric column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.