<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:33 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-552] What doesn&apos;t JSONParser support the /{regex}/i syntax for regular expressions?</title>
                <link>https://jira.mongodb.org/browse/JAVA-552</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I need to implement regular expression based search on a collection that exists on my production system.  Lets say the collection is called User and the search needs to take place on the Name field.  Two use cases are required:&lt;/p&gt;

&lt;p&gt;1. User provides a keyword and all User instances are returned where Name contains the provided keyword.  This translates nicely into the query:&lt;/p&gt;

&lt;p&gt;{ name : &lt;/p&gt;
{ $regex : &quot;simp&quot;, $options : &quot;i&quot; }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;The Java code works well for this use case.&lt;/p&gt;

&lt;p&gt;2. User provides a keyword and all User instances are returned where Name does not contain the provided keyword.  This needs to translate into the following query:&lt;/p&gt;

&lt;p&gt;{ name : &lt;/p&gt;
{ $not : /simp/i }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;since $not is not supported with $regex.&lt;/p&gt;

&lt;p&gt;However, I cannot pass a string value containing this query to JSONParser because it throws a parse exception.  I understand that they query is not valid JSON but works fine when executed directly from the Mongo console.&lt;/p&gt;

&lt;p&gt;Therefore, the question is, why doesn&apos;t JSONParser correctly translate the second query string into a valid DBObject?&lt;/p&gt;</description>
                <environment></environment>
        <key id="36066">JAVA-552</key>
            <summary>What doesn&apos;t JSONParser support the /{regex}/i syntax for regular expressions?</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="1" iconUrl="https://jira.mongodb.org/images/icons/priorities/blocker.svg">Blocker - P1</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="manish.in.java">Manish</reporter>
                        <labels>
                    </labels>
                <created>Thu, 12 Apr 2012 08:18:43 +0000</created>
                <updated>Wed, 11 Sep 2019 19:12:58 +0000</updated>
                            <resolved>Fri, 13 Apr 2012 13:14:48 +0000</resolved>
                                    <version>2.7.2</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="109530" author="jeff.yemin" created="Fri, 13 Apr 2012 13:14:48 +0000"  >&lt;p&gt;Manish, thank you for the suggestion, but we&apos;re going to have to have to leave it the way it is.&lt;/p&gt;</comment>
                            <comment id="109117" author="scotthernandez" created="Thu, 12 Apr 2012 14:49:52 +0000"  >&lt;p&gt;As you said, it is not valid json. The mongo javascript shell is a javascript interpreter not just a json parser &amp;#8211; there are many things you can do there which aren&apos;t valid json like declaring functions or writing loops for example.&lt;/p&gt;

&lt;p&gt;The mongodb json parser works fine with this &apos;{$not:{ $regex : &quot;simp&quot;, $options : &quot;i&quot; }}&apos; and it can be sent to the server without error; the regex gets converted to a Pattern object. &lt;/p&gt;

&lt;p&gt;In general you should not be using strings to build queries like this. &lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhb6n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14612</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>