使用次要索引和Timeuuid列上的范围进行搜索会更改范围搜索的顺序

时间:2017-08-25 12:20:15

标签: cassandra cassandra-2.0 cassandra-2.1 cassandra-3.0

我的表架构如下: -

create table test ( 
 devicename text, 
 date text,
 id timeuuid,
 code text,
 flag int,
 primary key (devicename, date, id)
) with clustering order by ( date desc , id desc )

CREATE CUSTOM INDEX code_idx ON test (code) USING 'org.apache.cassandra.index.sasi.SASIIndex'
WITH OPTIONS = { 'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer',
'case_sensitive': 'false' };

现在,我的选择查询是: -

select * from test where devicename = 'ABC' 
and id > minTimeuuid('2017-08-25 00:00:00') and id < maxTimeuuid('2017-08-25 23:59:59') allow filtering;

它给出了结果。现在,如果我想使用二级索引,搜索顺序会反转: -

Select * from test where devicename = 'ABC' 
and id > minTimeuuid('2017-08-25 00:00:00') and id < maxTimeuuid('2017-08-25 23:59:59')
and code like '%25%' allow filtering;

上面的代码给出0结果,而当我在搜索中更改timeuuid列的顺序时,它给出了正确的结果: -

Select * from test where devicename = 'ABC' 
and id < minTimeuuid('2017-08-25 00:00:00') and id > maxTimeuuid('2017-08-25 23:59:59')
and code like '%25%' allow filtering;

我的表架构仍未更改,即它显示id是降序,然后当我在select中使用二级索引列时搜索顺序发生变化的原因。请告诉我出错的地方。

谢谢,

0 个答案:

没有答案
相关问题