[SERVER-23599] text index unique constraint violation Created: 07/Apr/16  Updated: 15/Apr/16  Resolved: 07/Apr/16

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

Type: Question Priority: Major - P3
Reporter: telmo sa Assignee: Kelsey Schubert
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-23619 Allow the delimiter set recognized by... Backlog
Participants:

 Description   

I have this index setup:

{
    "_fts" : "text",
    "_ftsx" : 1,
    "SiteId" : 1
}

unique.

I could only create it if I dont have _fts field with values like: archive-collections-2

When I try to:

> db.post.update({FriendlyUrl:'archivecollections2'},{$set:{FriendlyUrl:'archive-collections-2'}})

I get:

WriteResult({
        "nMatched" : 0,
        "nUpserted" : 0,
        "nModified" : 0,
        "writeError" : {
                "code" : 11000,
                "errmsg" : "E11000 duplicate key error collection: BlackAndWhite
_ROC.post index: FriendlyUrl_text_SiteId_1 dup key: { : \"2\", : 0.6666666666666
666, : 20 }"
        }
})

Notice it's using only \"2\" and thus it violates the unique constraint.

Is this supposed to happen?
Why is it not using the full archive-collections-2 ?

Thank you!



 Comments   
Comment by Kelsey Schubert [ 08/Apr/16 ]

Hi telmo.sa@gmail.com,

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Thank you,
Thomas

Comment by telmo sa [ 08/Apr/16 ]

Hi. Thank you.
We only went for that because it's case insensitive, se would otherwise
have created

{ friendlyurl:1, siteid:1 }

.
Any suggestion?
Once again thank you for your time.

Telmo

Comment by Kelsey Schubert [ 08/Apr/16 ]

Hi telmo.sa@gmail.com,

  • It is currently not possible configure the set of delimiters recognized by the text search tokenizer. I have filed a new feature request, SERVER-23619, on your behalf. Please feel free to vote for it and watch it for updates.
  • Please note that the behavior of unique text indexes is not very intuitive. Consequently, we do not recommend the use of unique text indexes and may prohibit the creation of unique text indexes in the future as part of SERVER-13810.

Kind regards,
Thomas

Comment by telmo sa [ 07/Apr/16 ]

Hi, thank you for the prompt answer.
I've been to that page. Is it possible for me to say 'don't to that for '-' chars ?
One other thing to add.
If I have a record with archive-collections, I am able to update other record to archive-collections-2. After this, if I try to update other record to archive-collections-1 it fails with the refered error...
Any sense?

Telmo

Comment by Kelsey Schubert [ 07/Apr/16 ]

Hi telmo.sa@gmail.com,

This is expected behavior as the dash character is a token delimiter. For additional information on tokenization delimiters, please review our documentation here.

Kind regards,
Thomas

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