geoSearch returns no results when not searching on indexed field

XMLWordPrintableJSON

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

      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
            Reporter:
            Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: