[SERVER-2247] geo query with regex against an array returns no results Created: 17/Dec/10  Updated: 12/Jul/16  Resolved: 06/Apr/11

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 1.6.5
Fix Version/s: 1.9.0

Type: Bug Priority: Major - P3
Reporter: Elisha Cook Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File geo_regex0.js    
Operating System: Linux
Participants:

 Description   

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!



 Comments   
Comment by auto [ 06/Apr/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: look inside indexed arrays for regexes fix for SERVER-2247
Branch: master
https://github.com/mongodb/mongo/commit/9193ff5d00829dccffc9572eb15a446bd4d2309e

Comment by Greg Studer [ 06/Apr/11 ]

Reproduces in 1.9

Generated at Thu Feb 08 02:59:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.