[SERVER-13810] Index option "unique" should be disallowed for text/geo indexes Created: 01/May/14  Updated: 28/Dec/23

Status: Backlog
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Backlog - Query Team (Inactive) Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 0
Labels: qi-geo, qi-text-search
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-13808 Index option "sparse" should be disal... Backlog
Assigned Teams:
Query Integration
Participants:
Case:

 Description   

The semantics of the {unique: true} option for text/geo indexes are implementation-specific, unintuitive, and not useful (for text indexes, this option enforces that no two documents can have the same term+score pair; for geo indexes, this option enforces that no two documents can have a point with the same geohash value).

This option is currently disallowed for hashed indexes.



 Comments   
Comment by Kyle Suarez [ 03/Aug/18 ]

It's definitely confusing to users, as those who are unaware of our stemming semantics will be confused (e.g. SERVER-35045):

mongos> db.unsharded.createIndex({text: "text"}, {unique: true})
{
        "raw" : {
                "shardingtest-rs1/kimchi:20001" : {
                        "createdCollectionAutomatically" : false,
                        "numIndexesBefore" : 1,
                        "numIndexesAfter" : 2,
                        "ok" : 1
                }
        },
        "ok" : 1,
        "operationTime" : Timestamp(1533317603, 2),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1533317603, 2),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}
mongos> db.unsharded.insert({text: "the quick black fox"})
WriteResult({ "nInserted" : 1 })
mongos> db.unsharded.insert({text: "quick black fox"})
WriteResult({
        "nInserted" : 0,
        "writeError" : {
                "code" : 11000,
                "errmsg" : "E11000 duplicate key error collection: test.unsharded index: text_text dup key: { : \"black\", : 0.6666666666666666 }"
        }
})

Comment by Charlie Swanson [ 16/Feb/18 ]

This isn't as easy as it sounds due to upgrade/downgrade concerns. We have to figure out what to do if such an index already exists in the catalog.

Generated at Thu Feb 08 03:32:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.