{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/19","labels_url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/19/comments","events_url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/19/events","html_url":"https://github.com/yiisoft/yii2-mongodb/issues/19","id":74720419,"number":19,"title":"Allow regex as search arguments","user":{"login":"alexandernst","id":89727,"avatar_url":"https://avatars.githubusercontent.com/u/89727?v=3","gravatar_id":"","url":"https://api.github.com/users/alexandernst","html_url":"https://github.com/alexandernst","followers_url":"https://api.github.com/users/alexandernst/followers","following_url":"https://api.github.com/users/alexandernst/following{/other_user}","gists_url":"https://api.github.com/users/alexandernst/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandernst/subscriptions","organizations_url":"https://api.github.com/users/alexandernst/orgs","repos_url":"https://api.github.com/users/alexandernst/repos","events_url":"https://api.github.com/users/alexandernst/events{/privacy}","received_events_url":"https://api.github.com/users/alexandernst/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-09T17:34:55Z","updated_at":"2015-05-10T08:55:09Z","closed_at":"2015-05-09T18:55:12Z","body":"MongoDB is able  to search regex directly, but currently there is no way (or I couldn't find one) to make Yii2 to actually tell MongoDB to use a regex instead of a String.\r\n\r\nExample: `MyModel::findAll([\"path\" => \"/^1/2/3//\"]);`\r\n\r\nI'd expect, somehow, to make Yii2 to tell MongoDB that I'm actually searching the `/^1/2/3//` regex, and not the `\"/^1/2/3//\"` string.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/comments/100604857","html_url":"https://github.com/yiisoft/yii2-mongodb/issues/19#issuecomment-100604857","issue_url":"https://api.github.com/repos/yiisoft/yii2-mongodb/issues/19","id":100604857,"user":{"login":"alexandernst","id":89727,"avatar_url":"https://avatars.githubusercontent.com/u/89727?v=3","gravatar_id":"","url":"https://api.github.com/users/alexandernst","html_url":"https://github.com/alexandernst","followers_url":"https://api.github.com/users/alexandernst/followers","following_url":"https://api.github.com/users/alexandernst/following{/other_user}","gists_url":"https://api.github.com/users/alexandernst/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandernst/subscriptions","organizations_url":"https://api.github.com/users/alexandernst/orgs","repos_url":"https://api.github.com/users/alexandernst/repos","events_url":"https://api.github.com/users/alexandernst/events{/privacy}","received_events_url":"https://api.github.com/users/alexandernst/received_events","type":"User","site_admin":false},"created_at":"2015-05-10T08:55:09Z","updated_at":"2015-05-10T08:55:09Z","body":"@klimov-paul I think this is not a proper fix as you can't always use `$regex` [see docs](http://docs.mongodb.org/manual/reference/operator/query/regex/#syntax-restrictions).\r\n\r\nOn the other hand, I just tried with\r\n\r\n\t$current_path = \"/70000/\";\r\n\t$query = new Query;\r\n\t$query->select(['short_id', 'path'])->from('category')->where([\"REGEX\", \"path\", \"/^$current_path/\"]); // Serch all paths that starts with \"/70000/\"\r\n\t$subcategories = $query->all();\r\n\r\nAnd the query that was ran in MongoDB is:\r\n\r\n\tfind({\r\n\t\t\"ns\":\"tests.category\",\r\n\t\t\"limit\":0,\"batchSize\":0,\"skip\":0,\"flags\":0,\r\n\t\t\"query\":{\r\n\t\t\t\"path\":{\r\n\t\t\t\t\"regex\":\"^/70000/\",\"flags\":\"\"\r\n\t\t\t}\r\n\t\t},\r\n\t\t\"fields\":{\"short_id\":true,\"path\":true},\r\n\t\t\"started_iterating\":false}\r\n\t)\r\n\r\nWhich doesn't seem to be valid. I can't find anywhere in MongoDB's docs the `regex` operator. I find only the [`$regex` operator](http://docs.mongodb.org/manual/reference/operator/query/regex/).\r\n\r\nI tried running that same query from `mongo-client` (debian 8) and I got no results:\r\n\r\n\t> db.category.find({ \"path\": { \"regex\": \"^/70000/\", \"flags\": \"\" } })\r\n\t> db.category.find({ \"path\": { $regex: \"^/70000/\" } })\r\n\t{ \"_id\" : ObjectId(\"554c80d127e11b99338b456e\"), \"short_id\" : NumberLong(80000), \"path\" : \"/70000/\", \"name\" : { \"en-US\" : \"Category 8 (80000)\" }, \"slug\" : { \"en-US\" : \"category-8\" } }\r\n\t{ \"_id\" : ObjectId(\"554d3b2a27e11b2e678b4568\"), \"short_id\" : \"c72674\", \"path\" : \"/70000/\", \"name\" : { \"en-US\" : \"Sf SWrf s W SWff\" } }\r\n\t{ \"_id\" : ObjectId(\"554d1c3827e11b2e678b4567\"), \"short_id\" : \"333fe6\", \"path\" : \"/70000/80000/\", \"name\" : { \"en-US\" : \"New category\" } }\r\n\r\nAm I doing something wrong?"}}