aql> INSERT INTO test.user (PK, pids, test2, test1) VALUES ('k1', MAP('{"test1": "t1", "test2": "t2", "test3":"t3", "test4":"t4", "test5":"t5"}'), "t2bin", "t1bin")
aql> INSERT INTO test.user (PK, pids, test2, test1) VALUES ('k2', MAP('{"test1": "t1", "test3":"t3", "test4":"t4", "test5":"t5"}'), "t2b", "t1b")
aql> INSERT INTO test.user (PK, pids, test2, test1) VALUES ('k3', MAP('{"test1": "t1", "test2":"t22", "test4":"t4", "test5":"t5"}'), "t2b", "t1b")
aql> CREATE MAPKEYS INDEX pidIndex ON test.user (pids) STRING
OK, 1 index added.
aql> select * from test.user in MAPKEYS where pids="test2"
+--------------------------------------------------------------------------------+---------+---------+
| pids | test2 | test1 |
+--------------------------------------------------------------------------------+---------+---------+
| MAP('{"test2":"t22", "test4":"t4", "test5":"t5", "test1":"t1"}') | "t2b" | "t1b" |
| MAP('{"test2":"t2", "test3":"t3", "test4":"t4", "test5":"t5", "test1":"t1"}') | "t2bin" | "t1bin" |
+--------------------------------------------------------------------------------+---------+---------+
我以您的格式插入了三条记录,一条在其映射(k2)中没有 test2 键。然后我在 MAPKEY 上创建了二级索引并运行了查询,给了我想要的结果。
AGGREGATE 用于在此记录结果集上运行流用户定义函数。您要运行的 UDF 代码是什么?
(AGGREGATE test.check_password("hii") ....暗示你有一个 test.lua 文件,它有一个 check_password() 函数,它接受一个字符串参数。)
您必须首先在 MAP 键上创建二级索引。未找到其报告索引。要检查您是否有索引,您可以执行以下操作:
aql> show indexes
+--------+--------+-----------+--------+-------+------------+--------+------------+----------+
| ns | bin | indextype | set | state | indexname | path | sync_state | type |
+--------+--------+-----------+--------+-------+------------+--------+------------+----------+
| "test" | "pids" | "MAPKEYS" | "user" | "RW" | "pidIndex" | "pids" | "synced" | "STRING" |
+--------+--------+-----------+--------+-------+------------+--------+------------+----------+
1 row in set (0.000 secs)
OK