2016-05-13 107 views
2

我正在嘗試爲我的集合添加一個唯一索引。 我寫代碼:在pyarango arangodb中創建唯一索引

conn = Connection() 
db = conn['textBook'] 
db['Users'].ensureHashIndex('word', unique = True); 

(有數據庫 '教科書' 與收集「用戶現有的。)

pyArango.theExceptions.CreationError:錯誤的參數。錯誤:{u'errorMessage':u'bad參數',u'errorNum':10,u'code':400,u'error':True}

在函數中創建索引時發生_create(raise CreationError(data ['errorMessage'],data))

哪些參數不正確?

+1

一個炎熱的猜測是,你需要指定創建了索引的字段,因爲你需要在JS:HTTPS:/ /docs.arangodb.com/IndexHandling/Hash.html - 這很可能像這樣映射到python:'{fields:[「word」]}';取決於實現只有添加括號[]才能獲得列表。 – dothebart

回答

5

您需要提供列表中的字段,因此試試這個:

db['Users'].ensureHashIndex(['word'], unique = True)