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

  • Home
  • SEARCH
  • 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 8877885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:34:40+00:00 2026-06-14T19:34:40+00:00

Current MongoDB documentation states the following: You may only have 1 geospatial index per

  • 0

Current MongoDB documentation states the following:

You may only have 1 geospatial index per collection, for now. While
MongoDB may allow to create multiple indexes, this behavior is
unsupported. Because MongoDB can only use one index to support a
single query, in most cases, having multiple geo indexes will produce
undesirable behavior.

However, when I create two geospatial indices in a collection (using Mongoose), they work just fine:

MySchema.index({
  'loc1': '2d',
  extraField1: 1,
  extraField2: 1
});

MySchema.index({
  'loc2': '2d',
  extraField1: 1,
  extraField2: 1
});

My question is this: while it seems to work, the MongoDB documentation says this could “produce undesirable behavior”. So far, nothing undesirable has not yet been discovered neither in testing or use.

Should I be concerned about this? If the answer is yes then what would you recommend as a workaround?

  • 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-14T19:34:42+00:00Added an answer on June 14, 2026 at 7:34 pm

    It is still not supported, so even although you can create two of them, it doesn’t mean they are actually used properly. I would investigate explain output, on the mongo shell and issue a few queries that make use of the loc and loc2 fields in a geospatial way. For example with:

    use yourDbName
    db.yourCollection.find( { loc: { $nearSphere: [ 0, 0 ] } } ).explain();
    

    and:

    db.yourCollection.find( { loc2: { $nearSphere: [ 0, 0 ] } } ).explain();
    

    And then compare what the explain information gives you. You will likely see that only the first created geo index is used for both searches. There are a few tickets in JIRA for this that you might want to vote on:

    • https://jira.mongodb.org/browse/SERVER-2331
    • https://jira.mongodb.org/browse/SERVER-3653
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a MongoDB collection containing nearly 40 million records. The current size of
I have a MongoDB collection with documents in the following format: { _id :
i have created and want to now import a dummy collection. one of the
Using PHP and MongoDB, i have a collection called users and another one called
I have a MongoDB collection called employees where there are documents like this: {
I want to store the current date generated from PHP into MongoDB collection as
I have a MongoDB collection as follows: comment_id (number) comment_title (text) score (number) time_score
I am following http://api.mongodb.org/scala/casbah/current/setting_up.html in order to use MongoDB with scala. I am new
I have a MongoDB (v2.2.0) collection that contains reference data. Periodically, I need to
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,

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.