什么是'分区关键部分:XXXX必须受到限制,因为其他部分是'

时间:2017-01-03 10:25:50

标签: cassandra spring-data

我创建了一个表,其主键是((A1,A2),A3,A4,A5) 我想使用cassandraTemplate.select(select,MyClass.class);选择一些记录。

select.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel.ONE);
select.where(QueryBuilder.eq("A1", A1))
      .and(QueryBuilder.eq("A2", A2))
      .and(QueryBuilder.eq("A3", A3)).limit(100).allowFiltering()
      .setReadTimeoutMillis(100 * 1000);

我收到以下错误: HTTP status 500 - Request processing failed; nested exception is org.springframework.cassandra.support.exception.CassandraInvalidQueryException: Partition key parts: A4 must be restricted as other parts are;

创作脚本:

Create Table TestTable (
  A1 ascii,
  A2 int,
  A3 int,
  A4 ascii,
  A5 int,
  A6 bigint,
  A7 bigint,
  A8 ascii,
  PRIMARY KEY ((A1, A2),A3, A4,A5)
)  WITH compression =  { 'sstable_compression' : 'DeflateCompressor', 'chunk_length_kb' : 64 }
    AND compaction =  { 'class' : 'LeveledCompactionStrategy' };

1 个答案:

答案 0 :(得分:1)

Create Table TestTable (
  A1 ascii,
  A2 int,
  A3 int,
  A4 ascii,
  A5 int,
  A6 bigint,
  A7 bigint,
  A8 ascii,
  PRIMARY KEY ((A1, A2,A3, A4),A5)
)  WITH compression =  { 'sstable_compression' : 'DeflateCompressor', 'chunk_length_kb' : 64 }
    AND compaction =  { 'class' : 'LeveledCompactionStrategy' };
我犯了一个错误。实际上,我桌上的主键是((A1,A2,A3,A4),A5)。