我創建了一個表和索引如下卡桑德拉通過二級索引搜索行,返回null
CREATE TABLE refresh_token ( user_id bigint, refresh_token text, access_token text, device_desc text, device_type text, expire_time timestamp, org_id bigint, PRIMARY KEY (user_id, refresh_token) ) WITH CLUSTERING ORDER BY (refresh_token ASC) CREATE INDEX i_access_token ON demodb.refresh_token (access_token);
之後我插入或刪除約百萬times.I'm發現數據時,我的用戶的後續查詢不能返回任何數據。實際上,數據中有這一行。
當我通過PRIMARY KEY
select * from refresh_token where user_id=405198 and refresh_token='E82B57D9D64BECDBD6B5602A72816BD19016323504F803116F66A32598E04298';
查詢它返回數據:
select * from refresh_token where user_id=405198 and refresh_token='E82B57D9D64BECDBD6B5602A72816BD19016323504F803116F66A32598E04298'; user_id | refresh_token | access_token | device_desc | device_type | expire_time | org_id ---------+------------------------------------------------------------------+------------------------------------------------------------------+-------------+-------------+--------------------------+-------------- 405198 | E82B57D9D64BECDBD6B5602A72816BD19016323504F803116F66A32598E04298 | E82B57D9D64BECDB16D4F3F9F81AC0EF7AF2C4B460CB0F33C9CEFA5846BA7BE1 | null | null | 2016-06-07 14:09:52+0800 | 481036337156
但是當我通過二級索引查詢時,它返回null。
select * from refresh_token where access_token ='E82B57D9D64BECDB16D4F3F9F81AC0EF7AF2C4B460CB0F33C9CEFA5846BA7BE1'; user_id | refresh_token | access_token | device_desc | device_type | expire_time | org_id ---------+---------------+--------------+-------------+-------------+-------------+--------
感謝
當我重新插入it.it搜索次要。 – quemilk
你對查詢使用CL = QUORUM或CL = ONE嗎? – shutty
嘗試重建索引:'nodetool rebuild_index demodb refresh_token i_access_token'。 – Aaron