当我尝试访问二级索引时,Aerospike抛出AEROSPIKE_ERR_INDEX_NOT_READABLE错误。使用以下语法创建索引
CREATE INDEX index_id ON test.class(id)STRING;
任何建议将不胜感激。
答案 0 :(得分:3)
aql> create index id1 on ns1.testset (1) string;
OK, 1 index added.
aql> show indexes
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| ns | bin | indextype | set | state | indexname | path | type |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| "ns1" | "1" | "NONE" | "testset" | "WO" | "id1" | "1" | "STRING" |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
[127.0.0.1:3000] 1 row in set (0.001 secs)
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| ns | bin | indextype | set | state | indexname | path | type |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| "ns1" | "1" | "NONE" | "testset" | "WO" | "id1" | "1" | "STRING" |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
[172.14.10.12:3000] 1 row in set (0.002 secs)
OK
aql> show indexes
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| ns | bin | indextype | set | state | indexname | path | type |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| "ns1" | "1" | "NONE" | "testset" | "RW" | "id1" | "1" | "STRING" |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
[127.0.0.1:3000] 1 row in set (0.001 secs)
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| ns | bin | indextype | set | state | indexname | path | type |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
| "ns1" | "1" | "NONE" | "testset" | "RW" | "id1" | "1" | "STRING" |
+-------+-----+-----------+-----------+-------+-----------+------+----------+
[172.14.10.12:3000] 1 row in set (0.002 secs)
OK
注意:1)创建索引时不需要分号,但不会引发错误。因此:
aql> create index id1 on ns1.testset (1) string
将是正确的方法。
2)发出命令创建索引后,根据数据大小,将花费一些时间来构建SI。检查状态:WO->索引尚不可读,但您可以插入记录,它们将被索引。当状态变为“ RW”时-读/写-您可以执行SI查询。
您不必重新启动Aerospike服务器。
答案 1 :(得分:0)
重新启动Aerospike之后,我可以使用新创建的索引。