2016-05-13 82 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) 
相关问题