Select with a low power column to enable filtering. ERROR: no secondary indexes in restricted columns support provided statements

CREATE TABLE test (
    type text,
    scope text,
    name text,
    version text,
    alias text,
    deleted boolean,
    PRIMARY KEY ((type, scope, name), version)
) WITH read_repair_chance = 0.0
   AND dclocal_read_repair_chance = 0.1
   AND gc_grace_seconds = 864000
   AND bloom_filter_fp_chance = 0.01
   AND caching = { 'keys' : 'ALL', 'rows_per_partition' : 'NONE' }
   AND comment = ''
   AND compaction = { 'class' : 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'min_threshold' : 4, 'max_threshold' : 32 }
   AND compression = { 'sstable_compression' : 'org.apache.cassandra.io.compress.LZ4Compressor' }
   AND default_time_to_live = 0
   AND speculative_retry = '99.0PERCENTILE'
   AND min_index_interval = 128
   AND max_index_interval = 2048;
CREATE INDEX test_alias ON test (alias);
CREATE INDEX test_type_index ON test (type);

This selection does not work:

select * 
from test 
where type = 'type' 
    and scope='scope' 
    and name='name'
    and deleted = false 
allow filtering;

and gives me:

No secondary indexes in restricted columns support the provided Operators: com.datastax.driver.core.exceptions.InvalidQueryException: No secondary indexes in restricted columns support the provided operators.

This selection works:

select * 
from test 
where type = 'type' 
    and scope='scope' 
    and deleted = false 
allow filtering;

This selection also works:

select * 
from test 
where type = 'type' 
    and scope='scope' 
    and name='name' 
allow filtering;

This selection also works:

select * 
from test 
where type = 'type' 
    and scope='scope' 
    and name='name'
    and version='version' 
allow filtering;

Any idea? I don’t want to create an index in a low power column, and I don’t understand why in some cases this query works (when I filter through 2 fields from the primary key and optionally the fields: deleted).

Cassandra Version: 2.1.14

, . ...

+4
1

, ( WHERE), , .

, , .

, (type, scope, name, deleted) deleted, type, scope, name. name type, scope ..

deleted , ( ), .

CREATE TABLE test (
     type text,
     scope text,
     name text,
     version text,
     alias text,
     deleted boolean,
     PRIMARY KEY (type, scope, name, deleted, version)
 );
select *  from test
  where type = 'type'
      and scope='scope'
      and name='name'
      and deleted = false;

select *  from test
  where type = 'type'
  and scope='scope'
  and name='name'
  and version='version'
  and deleted in (true,false);

and type='type', ( ).

, . , " ", , . , .

+2

Source: https://habr.com/ru/post/1652963/


All Articles