我試圖通過pymongo爲我的mongodb集合應用索引。我使用pymongo中的多字段索引
db[collection_name].ensure_index([("field_name" , "text"),("unique", 1), ("dropDups" , 1)])
和它的作品。但是現在如何將它應用於多個領域呢? 像這樣
db[collection_name].ensure_index([("field_name1" , "text"),("field_name2", "text"),("field_name3", "text"),("unique", 1), ("dropDups" , 1)])
我知道我們可以在蒙戈外殼db.collection.ensureIndex({"$**":"text"},{"name":"TextIndex"})
,但我不想給指數的所有領域。有人可以幫我嗎?從the doc of createIndex
要一個綜合指數,或單獨索引所需的文本字段? – Nishant
我想通過python腳本做複合/複合索引 – Mrunmayee