Cory Spencer
2012-04-30 04:37:25 UTC
Hi all -
We've been developing a project using MongoDB as a database and I've
run into an issue that I can't figure out. Some of our queries build
a large regular expression (we're attempting to match a list of
biological gene symbols against documents stored in mongo). However,
when the regular expression gets to be too large, MongoDB returns no
results, even though the expression *should match documents in the
database.
Here's an example that should work in the mongo interactive shell:
First I'll insert a document into the database consisting of 50,000
function (n) {
return (new Array(n + 1)).join(this);
}
However, once you exceed the 32764 character length, the regular
Thank you!
Cory
We've been developing a project using MongoDB as a database and I've
run into an issue that I can't figure out. Some of our queries build
a large regular expression (we're attempting to match a list of
biological gene symbols against documents stored in mongo). However,
when the regular expression gets to be too large, MongoDB returns no
results, even though the expression *should match documents in the
database.
Here's an example that should work in the mongo interactive shell:
First I'll insert a document into the database consisting of 50,000
String.prototype.repeat = function(n) { return new Array(n +
1).join( this )function (n) {
return (new Array(n + 1)).join(this);
}
db.example.insert({ field : "x".repeat(50000) })
Searching for it using a regular expression consisting of less than ordb.example.find({ field : { $regex : "x".repeat(32764) }})
"...." }However, once you exceed the 32764 character length, the regular
db.example.find({ field : { $regex : "x".repeat(32765) }})
Why is this and is there a work around?Thank you!
Cory