[SERVER-35045] Unique Index on a single text field has unexpected behavior with spaces Created: 17/May/18 Updated: 27/Oct/23 Resolved: 23/May/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Text Search |
| Affects Version/s: | 3.6.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Mathew Cabutage [X] | Assignee: | Backlog - Triage Team |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Server Triage
|
|||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||
| Steps To Reproduce: | Used the mongo shell on powershell.
|
|||||||||||||||||||
| Participants: |
| Description |
|
Applying a unique index to a single text field has unexpected behavior with spaces. OS: Windows 10 For example: Inserting "test co" and "test2 co" fail uniqueness. Inserting " co" and " co" fail uniqueness.
|
| Comments |
| Comment by Mathew Cabutage [X] [ 21/May/18 ] |
|
Thanks for the help Andy. You are right, this is not a bug, but user error. I should be just be indexing strings. As far as it possibly being a bug that mongodb allows the creation of a unique text index, I do see it possibly being useful when used with weights. You may close/delete the issue. |
| Comment by Andy Schwerin [ 18/May/18 ] |
|
It may be a bug that we allow you to create a unique text index. A text index splits strings into tokens (words), and those tokens form the keys. So in your example, "co" is a duplicates key. Are you trying to build a text index, or just index strings? If the latter, you need to change your index spec. |