I have a collection called englishWords, and the unique index is the "word" field. When I do this
from pymongo import MongoClient
tasovshik = MongoClient()
db = tasovshik.tongler
coll = db.englishWords
f = open('book.txt')
for word in f.read().split():
coll.insert( { "word": word } } )
I get this error message
pymongo.errors.DuplicateKeyError: E11000 duplicate key error index: tongler.englishWords.$word_1 dup key: { : "Harry" }, but it stops to insert when the first existing word is to be inserted.
I do not want to implement the check of existence, I want to use the benefits of unique index with no problems.