<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:00:52 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>[SERVER-2675] Multikeys (indexing keys in a hash) for ranged queries</title>
                <link>https://jira.mongodb.org/browse/SERVER-2675</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Mongo currently supports multikey indexing (where we index values in an array).  I suggest a feature for specifying an index on the keys and values of a given hash.  This would be synonymous to the common property bag pattern which is sometimes implemented in SQL datastores. &lt;/p&gt;

&lt;p&gt;properties (table)&lt;br/&gt;
==============&lt;br/&gt;
id (int, PK)&lt;br/&gt;
entity_id (int, FK)&lt;br/&gt;
key (varchar)&lt;br/&gt;
value (varchar)&lt;/p&gt;

&lt;p&gt;Sample data (date of birth for several different entities);&lt;br/&gt;
INSERT INTO properties (entity_id, key, value) VALUES (101, &apos;dob&apos;, &apos;12/15/1980&apos;)&lt;br/&gt;
INSERT INTO properties (entity_id, key, value) VALUES (276, &apos;dob&apos;, &apos;11/05/1973&apos;)&lt;br/&gt;
INSERT INTO properties (entity_id, key, value) VALUES (333, &apos;dob&apos;, &apos;11/05/1944&apos;)&lt;/p&gt;

&lt;p&gt;Index: key, value&lt;/p&gt;

&lt;p&gt;With an index in place we can find everyone born in the 70&apos;s.&lt;/p&gt;

&lt;p&gt;In Mongo, to accomplish the same you have to add an index directly to the &apos;dob&apos; attribute of the document.  This is undesirable as our goal is to allow our documents (of any type) to share the same collection.  (This is ideal for topic maps and social CMSes and many other use case, I&apos;m sure.)  It would be more useful if we could instead index the keys/values of a hash and perform ranged queries against those keys.  Any property added to the property bag would be indexed.  Powerful!&lt;/p&gt;

&lt;p&gt;INSERT INTO properties (entity_id, key, value) VALUES (101, &apos;iq&apos;, 83)&lt;br/&gt;
INSERT INTO properties (entity_id, key, value) VALUES (276, &apos;iq&apos;, 120)&lt;br/&gt;
INSERT INTO properties (entity_id, key, value) VALUES (333, &apos;iq&apos;, 103)&lt;/p&gt;

&lt;p&gt;Now we&apos;ve added &quot;IQ&quot; to our entities.  We can just as easily perform a greater-than query to grab the smartest people from our collection of whatevers.&lt;/p&gt;

&lt;p&gt;I believe this approach is superior to the current multikey approach suggested on:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/Using+Multikeys+to+Simulate+a+Large+Number+of+Indexes&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Using+Multikeys+to+Simulate+a+Large+Number+of+Indexes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The future seems to be all about schema-less DBs.  Indexing a hash of keys/values seems totally in tune with what it means to be schema-less.  Also, you should be able to use hash indexing as part of a compound index.  This would be especially important as one of the indexables would probably be type.&lt;/p&gt;

&lt;p&gt;db.whatevers.index({type: 1, attributes: &lt;/p&gt;
{ $hidx: 1}
&lt;p&gt;) // $hidx = hash (key/value) index&lt;br/&gt;
db.whatevers.find({&apos;type&apos;: &apos;person&apos;, &apos;attributes.iq&apos;: {$gt: 100}}) //uses index (not scan)&lt;br/&gt;
db.whatevers.find({&apos;type&apos;: &apos;person&apos;, &apos;attributes.dob&apos;: {$gte: &apos;1/1/1970&apos;, $lte: &apos;12/31/1970&apos;}}) //uses the same index&lt;/p&gt;

&lt;p&gt;The document might look like:&lt;br/&gt;
{&lt;br/&gt;
  type: &quot;Person&quot;,&lt;br/&gt;
  attributes: &lt;/p&gt;
{
    name: &quot;Jason&quot;,
    dob: &apos;12/01/1950&apos;,
    iq: 99
  }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Attributes expressed in this manner seems more natural than:&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
  type: &quot;Person&quot;,&lt;br/&gt;
  attributes: [&lt;br/&gt;
    &lt;/p&gt;
{name: &quot;Jason&quot;}
&lt;p&gt;,&lt;br/&gt;
    &lt;/p&gt;
{dob: &apos;12/01/1950&apos;}
&lt;p&gt;,&lt;/p&gt;
    {iq: 99}
&lt;p&gt;  ]&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Futhermore, as far as I can tell, the multikey style doesn&apos;t support ranged queries.&lt;/p&gt;

&lt;p&gt;Thanks for reading.  MongoDB is a great work!&lt;/p&gt;</description>
                <environment></environment>
        <key id="14989">SERVER-2675</key>
            <summary>Multikeys (indexing keys in a hash) for ranged queries</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="backlog-query-optimization">Backlog - Query Optimization</assignee>
                                    <reporter username="mlanza">Mario T. Lanza</reporter>
                        <labels>
                    </labels>
                <created>Fri, 4 Mar 2011 04:30:20 +0000</created>
                <updated>Tue, 6 Dec 2022 05:44:55 +0000</updated>
                            <resolved>Mon, 3 May 2021 20:28:15 +0000</resolved>
                                    <version>features we&amp;#39;re not sure of</version>
                                    <fixVersion>features we&amp;#39;re not sure of</fixVersion>
                                    <component>Internal Client</component>
                                        <votes>3</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="3752863" author="charlie.swanson" created="Mon, 3 May 2021 20:28:15 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I was just searching across old tickets and I noticed this request was actually completed I believe. In 4.2 we released &lt;a href=&quot;https://docs.mongodb.com/manual/core/index-wildcard/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;Wildcard Indexes&quot;&lt;/a&gt; to index any attribute with an unpredictable name.&lt;/p&gt;

&lt;p&gt;I&apos;m closing this ticket as &quot;Done&quot; because I believe we&apos;ve met the initial request. Please let me know if there is still something missing from &quot;Wildcard Indexes&quot; that you&apos;d like to see for this use case. &lt;/p&gt;</comment>
                            <comment id="25203" author="mlanza" created="Fri, 4 Mar 2011 04:39:40 +0000"  >&lt;p&gt;One potential issue: I suppose there could be attributes that could be extremely lengthy (e.g. the &quot;body&quot; property of an essay, the equivalent of the SQL text datatype).  In this case you might have to limit how many characters are indexed.&lt;/p&gt;

&lt;p&gt;db.whatevers.index({type: 1, attributes: &lt;/p&gt;
{ $hidx: 1, $max_chars: 200}
&lt;p&gt;) &lt;/p&gt;

&lt;p&gt;Of course, this would only be applicable on text values and there would be an implied upper limit if the option was omitted.&lt;/p&gt;

&lt;p&gt;Also, this might be a better way of expressing the index:&lt;/p&gt;

&lt;p&gt;db.whatevers.index(&lt;/p&gt;
{&apos;type&apos;: 1, &apos;attributes.*&apos;: 1}
&lt;p&gt;)&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="606647">SERVER-37188</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="10498">SERVER-267</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25126"><![CDATA[Query Optimization]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 4 Dec 2017 19:58:24 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 40 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 40 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>mlanza</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp4nz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr4j0n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6587</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hskzn3:</customfieldvalue>

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