[SERVER-969] There is a limit on the number regexes in a query Created: 05/Apr/10  Updated: 12/Jul/16  Resolved: 16/Nov/11

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 2.1.0

Type: Improvement Priority: Major - P3
Reporter: Shimon Cohen Assignee: Eric Milkie
Resolution: Done Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

GNU/Linux (Debian)


Issue Links:
Related
Participants:

 Description   

When querying with more than 4 regex clauses, the serve emits an error message:
ERROR: too many regexes in query.
The resultant reply is a set of object of the same query but ignoring the "extra" regex.

It would be nice to have this limit removed.



 Comments   
Comment by auto [ 16/Nov/11 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: Allow more than four regular expressions in a query SERVER-969
prior behavior was to log an error message and ignore any further regexps past 4
new behavior is to allow as many regexps as desired.
Branch: master
https://github.com/mongodb/mongo/commit/62554d064a264f9b6c28099ba71421f250bbbba9

Comment by rgpublic [ 20/May/11 ]

Just accidentally read about this limitation here which might quite soon turn out to be highly problematic for us and severly limit what we are planning to achieve with MongoDB. Has anyone any experience what happens if you remove the above-mentioned limit from the source and recompile? Which file needs to be changed exactly? We would even accept if the query is running slower. Or is it better to replace all regexes beyond 4 to $function?

Comment by Marco Ponton [ 19/May/11 ]

Hi guys,

This limitation is really bugging me. I do a GeoSpatial search to return a limited number of documents that I then want to filter using multiple regexes but I just found out (the long way) that I am limited to 4. I could do it client-side, but it complicates things and I have to deal with "skip" and "limit" logic. Its ugly. If this limit was put there for performance reasons, why not just remove it and let the end-user deal with any issue?

On another note: I don't want to complain too much because you are doing an incredible job and we all appreciate the hard work put in MongoDB. Still, I am a bit frustrated by the way this limitation is handled. Seriously? A one-liner in the server log? I've spent way to much time tracking down this issue because when it happens, the server just happily spit out results matching the first 4 regexes. Notifying the client of the error would be the least you should until the limitation is removed. If this alone is too much work, could you please update the documentation for "Regular Expressions" in "Advanced Queries" to clearly mention this limitation?

Thanks!

Comment by Andrew Armstrong [ 10/Mar/11 ]

Looking at the source its just a hard coded, arbitrary limit:

...

void Matcher::addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot) {

if ( nRegex >= 4 )

{ out() << "ERROR: too many regexes in query" << endl; }

....

I assume the reason for it is because any more regexes and performance may begin to suffer?

Comment by Eliot Horowitz (Inactive) [ 10/Mar/11 ]

Note the "Fix Version" above.
That means its stuff we hope to get done this year, but the # of votes is not that high compared to other enhancements.

Comment by prashant sharma [ 10/Mar/11 ]

Hi,

I am using 1.6.5. I was wondering if this issue is likely to be fixed soon?

Prashant

Comment by Vadim Pavlov [ 01/Mar/11 ]

Very important bug. Because we cant use this database in big portals, which needs to filter data by many expressions.
Please resolve it.

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