I have a very large csv that I'm trying to search through. I've decided to use MongoDB and load in the whole csv so I can quickly search through it later with python and pymongo, instead of having to load all 80MB each time I try a search. What I can't figure out, is how to search through the collection for a given user agent and match it to the regex that is in the item's '_id' field. I first process the browscap entry to a python rege, then insert the item into the mongo collection.
How do I search with pymongo a given user agent for a regex mongoID?
Example User Agent:
AppleCoreMedia/1.0.0.12B440 (iPad; U; CPU OS 8_1_2 like Mac OS X; en_us)
Example Browscap Entry:
AppleCoreMedia/1.0* (iPhone*CPU OS 8* like Mac OS X*)*
Example Regex Mongo ID:
^AppleCoreMedia\/1\\.0.\*?\\ \\(iPhone.*?CPU\\ OS\\ 8.*?\\ like\\ Mac\\ OS\\ X.*?\\).*?$
_id? Or is just the user agent string stored in the_idand you want to search with a regex? For the former case you need the$whereevalution as mentioned in MongoDB reverse regex. Thought it's notably not a good performer, and you might want to rethink what you are doing here if that is the case.