在Cassandra中创建自定义索引时说'json_idx' 我们有能力使用
删除该索引DROP INDEX json_idx;
有没有办法查看索引表的内容? (类似SELECT *来自FROM,SHOW或DESC)
谢谢
答案 0 :(得分:1)
查看原始sstables的工具是C*/tools/bin
中的sstable2json。你可以按如下方式使用它(例子包括ks和cf creation / population):
cqlsh> CREATE KEYSPACE example WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1 };
cqlsh> CREATE TABLE example.table1 (id timeuuid, data text, PRIMARY KEY(id));
cqlsh> CREATE INDEX table1_data_idx on example.table1 (data);
cqlsh> INSERT INTO example.table1 (id, data) VALUES (now(), '1');
cqlsh> INSERT INTO example.table1 (id, data) VALUES (now(), '2');
cqlsh> INSERT INTO example.table1 (id, data) VALUES (now(), '3');
cqlsh> INSERT INTO example.table1 (id, data) VALUES (now(), '4');
$ ./bin/nodetool flush
$ ./tools/bin/sstable2json data/data/example/table1-c6163220ede311e4b03c5950fe1805c6/.table1_data_idx/la-1-big-Data.db
[
{"key": "1", "cells": [["33a44ed0ede411e4b03c5950fe1805c6","",1430252510243205]]},
{"key": "2", "cells": [["34e189c0ede411e4b03c5950fe1805c6","",1430252512347428]]},
{"key": "3", "cells": [["362c5940ede411e4b03c5950fe1805c6","",1430252514515429]]},
{"key": "4", "cells": [["373c90c0ede411e4b03c5950fe1805c6","",1430252516299193]]}
]
重要的部分是在sstable2json的路径中添加索引cf,路径如下:
<data_dir>/data/<KS>/<CF-uid>/<secondary-index>/<data-sstable>