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 9015119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:40:20+00:00 2026-06-16T03:40:20+00:00

I have a query that’s supposed to do the following: Take two sets of

  • 0

I have a query that’s supposed to do the following:
Take two sets of coordinates and return the locations that are near any of the coordinates.

I’m working on Node.js with Mongoose.js.

The original query code is below (before I tried using the query.or() syntax:

query.or([{geoNear: "loc", near: start, spherical: true},{geoNear: "loc", near: end}]);

The issue seems to be using the $or because I initially tried the code as:

            that.count({
                _cat: _cat ,
                $or: [
                    {
                        loc: { $nearSphere: start }
                    },
                    {
                        loc: { $nearSphere: end }
                    }
                ]}, function(err, c) {
                    // do something
                });

When I search using one location without the $or (i.e. start or end) I am able to get results. That is how I’m certain that the problem is with the $or.

Does mongoDB/mongoose support using $or with geospatial search, or am I doing something wrong?

  • 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-16T03:40:22+00:00Added an answer on June 16, 2026 at 3:40 am

    It seems that $or does not work, so I have opted for running 2 queries for now, then evaluating the result of each in order to return the count. It works for me because I don’t need the actual count, but I need to know if there are any locations available within a certain distance of each point.

    If anyone has a similar problem, and use this approach as a work-around, remember to nest the second query in the callback of the first query. This is obviously more problematic when you have more than 2 locations that you’re querying.

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

Sidebar

Related Questions

i have a query that in a sub query calculates amount by dividing two
I have this query that return to me all rows for one user $strSQL
I have a query that produces the following results: { data: [ { id:
I have a query that is meant to return user details from Wordpress tables.
I have a query that returns data in the following form attribute value ---------
I have a Query that's supposed to run like this - If(var = xyz)
I have query that I run on Oracle that is supposed to allow hyphen
Lets say I have query that gets following List Item Objects with Set of
I have a query that performs a UNION between two tables. I'm trying to
I have a query that counts the price of all items between two dates.

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.