如何匹配 RethinkDB 中的嵌套值?

How to match nested values in RethinkDB?

我使用 Python 客户端驱动程序,我的文档结构是:

{"key1": ["value1"], "key2": ["value2"], ..., "key7": ["value7"]}

假设 "value7" 是 "In every time in every place, deeds of men remain the same"

我想检索包含 "deed" 键 7 的所有文档。

我试过了

r.db('db')
 .table('table')
 .filter(lambda row: row['key7'].match('^deed'))
 .run(conn)

但它不起作用...我收到以下消息:

rethinkdb.errors.ReqlQueryLogicError: Expected type STRING but found ARRAY

解决方法如下:

r.db('db')
 .table('table')
 .filter(lambda row: row['key7'].nth(0).match('^deed'))
 .run(conn)