[CSHARP-862] Regex Queries /s suffix Created: 14/Nov/13 Updated: 05/Apr/19 Resolved: 14/Nov/13 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.8.3 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Huseyin Yurtseven | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Hello, You've used an s suffix for the regex clauses and i think because of that suffix index selection and profile output is not working correctly. You can not use find() for profile collection because it gives an error message about s suffix. var options = caseInsensitive ? "is" : "s"; When i change the above line with var options = caseInsensitive ? "i" : ""; line, everything is going well. But is there a reason for that "s" suffix. |
| Comments |
| Comment by Huseyin Yurtseven [ 14/Nov/13 ] |
|
Thank for your helps. You're right if you change the driver behaviour someone's code would not work. So i will be waiting for server and shell issues. Thanks again. |
| Comment by Craig Wilson [ 14/Nov/13 ] |
|
Ok, figured out what is going on. I've linked Unfortunately, there really isn't a whole lot we, the .NET driver team, can do at this point. If we remove the /s option from LINQ queries, we'll likely break someone who was relying on the behavior. However, there is a workaround for you. Instead of using StartsWith, you can use Regex.IsMatch(input, pattern, RegexOptions.None). Basically, as long as you do NOT include RegexOptions.SingleLine, then the s will not get included as a suffix. Sorry it took me this long to figure out what was going on. As far as this ticket is concerned, I don't think there is any work to be done in the driver, so I'd like to close it. Let me know if that is ok or if there is anything else I can do to help in regards to this issue. |
| Comment by Huseyin Yurtseven [ 14/Nov/13 ] |
|
Yes i'm referring to the system.profile collection. I'm using mongodb 2.2 version and i'm not sure but after remove that /s option my query's response time decreased. |
| Comment by Craig Wilson [ 14/Nov/13 ] |
|
Are you referring to the system.profile collection (http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/) or some other collection? If some other collection, could you please provide some sample documents? Also, what version of MongoDB are you using? |
| Comment by Huseyin Yurtseven [ 14/Nov/13 ] |
|
Actually i use Linq startswith and mongo driver always put /s option and because of this s option i cannot look into profile collection, it gives an error about s option and i cannot use /s option on mongo shell it gives an error as well. That's why i wanted to ask. Thank you. |
| Comment by Craig Wilson [ 14/Nov/13 ] |
|
Perhaps you could show the regular expression you are using. The s suffix allows the '.' character to match newline characters as documented here: http://docs.mongodb.org/manual/reference/operator/query/regex/. |