I’d like to use the standard MongoDB ReST interface ( http://www.mongodb.org/display/DOCS/Http+Interface ) to search for and return records with a wildcard match on a certain field – ‘link_url’ in this case. For instance passing ‘acko’ to match http://www.stackoverflow.com etc.
It looks like if I wanted an exact match I would use
http://127.0.0.1:28017/databaseName/collectionName/?filter_link_url=value
But I’d like to pass a regex to allow the partial match
I’ve tried combining the URL above in various ways with syntax like their snippet:
"match" : { "$regex" : "foo", "$options" : "ig" }
But had no luck. Can anyone help? I only need to do finds and ideally don’t want to have to run another interface.
It looks like the REST interface (likely for safety), automatically escapes the fields passed through, and that embedded queries are not possible. What that means is both methods for passing in the required URL format seem to be excluded. For example:
This would translate to, in theory:
Unfortunately, that actually gets passed as (note the quotes):
There are similar issues with the other form where you pass in the $regex command as an embedded document. This, and other issues are why the built-in REST interface is not the recommended solution for running queries against mongoDB. Instead you should look at Sleepy Mongoose), or node.js
I know you didn’t want to use another interface, but sometimes it really is the best thing to do.