geo query with regex against an array returns no results

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9.0
    • Affects Version/s: 1.6.5
    • Component/s: Geo
    • None
    • Linux
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Here's an example using pymongo. I'm able to duplicate with different types of geo queries:

      import re
      from pymongo import Connection

      coll = Connection().test.georegexlistfail
      coll.ensure_index([('point', '2d'), ('words', 1)])
      coll.insert({
      'point': [1, 1],
      'words': ['foo', 'bar']
      })

      q_regex =

      {'words': re.compile('^f')}

      q_geo = {'point': {'$near':[1,1]}}
      q_both =

      {'words': q_regex['words'], 'point': q_geo['point']}

      def run(q):
      print 'Query: %s' % str(q)
      print 'Result: %s' % str(coll.find_one(q))
      print

      run(q_regex)
      run(q_geo)
      run(q_both)

      """
      Output:

      Query:

      {'words': <_sre.SRE_Pattern object at 0x7f9fc21b63b0>}

      Result:

      {u'_id': ObjectId('4d0be668b45b5d4d2d000000'), u'words': [u'foo', u'bar'], u'point': [1, 1]}

      Query: {'point': {'$near': [1, 1]}}
      Result:

      {u'_id': ObjectId('4d0be668b45b5d4d2d000000'), u'words': [u'foo', u'bar'], u'point': [1, 1]}

      Query: {'words': <_sre.SRE_Pattern object at 0x7f9fc21b63b0>, 'point': {'$near': [1, 1]}}
      Result: None
      """

      Thanks!

            Assignee:
            Greg Studer (Inactive)
            Reporter:
            Elisha Cook
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: