[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:
Depends
depends on SERVER-4645 The shell's db.collection.find() comm... Closed
Related
is related to SERVER-9035 Regex "s" option causes mongo to use ... Closed

 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 SERVER-4645 as this appears to be a server issue. /s is a legal suffix, but the shell simply doesn't recognize it. Hence, when querying from the profile collection in the shell, there is an issue loading up queries that contained this suffix. However, it is entirely possible to query the system.profile collection from the .NET driver, and likely any other driver. It truly is a shell issue. I've also linked SERVER-9035 which indicates a performance issue with the /s flag.

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/.

Generated at Wed Feb 07 21:38:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.