Mongodb text index Duplicate Key Error when part of string field same
问题 For examples: doc1: { 'name':'apple' } doc2: { 'name':'apple juice' } when I create text index with pymongo: db.products_collection.create_index([('name', TEXT)], unique=True, background=True) it give me an error: E11000 duplicate key error collection: c.items_collection index: name_text_alias_text dup key: { : "apple", : 10.5 } Some one know why? I cannot add unique=True for text string? 回答1: A text index splits strings into tokens (words), and those tokens form the keys. So in your example,