Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-23158

geoSearch returns no results when not searching on indexed field

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo
    • Labels:
      None
    • ALL

      It doesn't error and claims to succeed, but the results array is empty when it shouldn't be.

      db.coll.insert({_id: 1, point: [0, 0], indexed: 1, unindexed: 1});
      assert.commandWorked(db.coll.ensureIndex({point: 'geoHaystack', indexed: 1}, { bucketSize:1}));
      function geoSearch(search) {
          return assert.commandWorked(
              db.coll.runCommand('geoSearch', {near: [0, 0], maxDistance: 1, search: search}));
      }
      
      // Try with search on indexed field. (works)
      assert.eq(geoSearch({indexed: 1}).results.length, 1, "indexed");
      
      // Try with search on unindexed field. (fails)
      assert.eq(geoSearch({unindexed: 1}).results.length, 1, "unindexed");
      
      // Try with empty search. (fails)
      assert.eq(geoSearch({}).results.length, 1, "empty");
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: