<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:48 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-1097] deprecate ensureIndex() methods</title>
                <link>https://jira.mongodb.org/browse/JAVA-1097</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Deprecate DBCollection.ensureIndex (all overloads) and DBCollection.resetIndexCache.  Caching of which indexes have been created is really not something the driver should be doing, as it is prone to race conditions with other clients.&lt;/p&gt;</description>
                <environment></environment>
        <key id="108391">JAVA-1097</key>
            <summary>deprecate ensureIndex() methods</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="justin.lee">Justin Lee</assignee>
                                    <reporter username="justin.lee">Justin Lee</reporter>
                        <labels>
                    </labels>
                <created>Thu, 30 Jan 2014 16:32:16 +0000</created>
                <updated>Fri, 11 Dec 2015 10:39:53 +0000</updated>
                            <resolved>Thu, 30 Jan 2014 18:19:23 +0000</resolved>
                                    <version>2.12.0</version>
                                    <fixVersion>2.12.0</fixVersion>
                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="1111884" author="nitin.dandriyal@gmail.com" created="Fri, 11 Dec 2015 10:39:53 +0000"  >&lt;p&gt;Thanks Ross Lawley, I was afraid because it seems that the handling of DBCollection.createIndex() is different for mongodb server version prior to 2.6 &lt;/p&gt;</comment>
                            <comment id="1111858" author="ross@10gen.com" created="Fri, 11 Dec 2015 09:55:14 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=nitin.dandriyal%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;nitin.dandriyal@gmail.com&quot;&gt;nitin.dandriyal@gmail.com&lt;/a&gt; - thats fine as &lt;tt&gt;DBCollection.createIndex()&lt;/tt&gt; will only create the index if it doesn&apos;t already exist.&lt;/p&gt;</comment>
                            <comment id="1111856" author="nitin.dandriyal@gmail.com" created="Fri, 11 Dec 2015 09:52:13 +0000"  >&lt;p&gt;Hi Justin Lee,&lt;/p&gt;

&lt;p&gt;I am upgrading from driver version 2.9.3 to 3.2.0-rc0&lt;br/&gt;
Mongo Server version : 2.4.5&lt;/p&gt;

&lt;p&gt;I was using DBCollection.ensureIndex() method during application start, now while upgrading I saw that this method has been removed. Can I directly use DBCollection.createIndex()? I am worried, after change I do not end up rebuilding indexes everytime my application starts. Thanks in advance&lt;/p&gt;</comment>
                            <comment id="742720" author="jeff.yemin" created="Thu, 16 Oct 2014 13:14:43 +0000"  >&lt;p&gt;One clarification: there is no such thing as ensureIndex on the server: ensureIndex is just a MongoDB shell/driver helper method.  Until MongoDB 2.6 there was no command to create an index.  Driver implementations just inserted a document in the special system.indexes collections.  MongoDB 2.6 introduced the &lt;a href=&quot;http://docs.mongodb.org/manual/reference/command/createIndexes/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;createIndexes&lt;/a&gt; command, which allows you to create multiple indexes at once, potentially in parallel.  As of 2.12.0, the Java driver implementation of both ensureIndex and createIndex will detect the server version and use the createIndexes command if it&apos;s available (though there is currently no helper that exposes the ability of createIndexes to create multiple indexes).&lt;/p&gt;
</comment>
                            <comment id="742594" author="jgrivolla" created="Thu, 16 Oct 2014 08:38:03 +0000"  >&lt;p&gt;Thanks for your reply, I think this should be clearer in the documentation. It is very confusing like this, and people are getting misled: &lt;a href=&quot;https://stackoverflow.com/questions/25968592/difference-between-createindex-and-ensureindex-in-java-using-mongodb/26386601&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://stackoverflow.com/questions/25968592/difference-between-createindex-and-ensureindex-in-java-using-mongodb/26386601&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In summary, if I understand correctly, `createIndex` in Java corresponds to `ensureIndex` on the server, but it can&apos;t be called that because there was another method with that name earlier that had to be deprecated because it was broken. Couldn&apos;t the name `ensureIndex` be reused on the Java side with the correct functionality (i.e. server side `ensureIndex` instead of client side index caching)?&lt;/p&gt;</comment>
                            <comment id="742580" author="ross@10gen.com" created="Thu, 16 Oct 2014 07:46:38 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jgrivolla&quot; class=&quot;user-hover&quot; rel=&quot;jgrivolla&quot;&gt;jgrivolla&lt;/a&gt;, its an unfortunate artefact about the behaviour of &lt;tt&gt;ensureIndex&lt;/tt&gt; that has led it to being deprecated. Drivers shouldn&apos;t cache if an index has been created or not as they aren&apos;t wholly in possession of that information, this has in the past caused issues to users. So the decision was made to deprecate this behaviour in drivers that supported it.&lt;/p&gt;

&lt;p&gt;In reality &lt;tt&gt;ensureIndex&lt;/tt&gt; on the server and &lt;tt&gt;createIndex&lt;/tt&gt; in the driver will do the same thing and will not error if an index already exists.  In the future we&apos;ll work closer to ensure the shell api and the drivers api follow the same theme.&lt;/p&gt;</comment>
                            <comment id="741781" author="jgrivolla" created="Wed, 15 Oct 2014 15:48:21 +0000"  >&lt;p&gt;Why is this exactly opposite of the general MongoDB API? Does the Java createIndex() correspond to MongoDB&apos;s ensureIndex() or does this mean that Java users have to use a method that&apos;s actually deprecated in MongoDB?&lt;/p&gt;</comment>
                            <comment id="490952" author="xgen-internal-githook" created="Thu, 30 Jan 2014 18:18:56 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;evanchooly&apos;, u&apos;name&apos;: u&apos;Justin Lee&apos;, u&apos;email&apos;: u&apos;justin.lee@10gen.com&apos;}
&lt;p&gt;Message: fixes &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1097&quot; title=&quot;deprecate ensureIndex() methods&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1097&quot;&gt;&lt;del&gt;JAVA-1097&lt;/del&gt;&lt;/a&gt; deprecate ensureIndex() methods&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/5d22fd734370d644cbf403012c1885de6787fb06&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/5d22fd734370d644cbf403012c1885de6787fb06&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="108392">JAVA-1098</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="174933">DOCS-4539</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="174943">DOCS-4540</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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|hrt6bb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>84106</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="82">Sprint 3</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>