【发布时间】:2018-03-16 01:32:06
【问题描述】:
我有以下代码
@Indexed
@PrimaryKeyColumn(name = "x", ordinal = 1, type = PrimaryKeyType.PARTITIONED)
@Column(value="x")
private String x;
@Indexed
@PrimaryKeyColumn(name = "code", ordinal = 2, type = PrimaryKeyType.PARTITIONED)
@Column(value="code")
private String code;
@Query(value = "select * from customers where code = ?0")
Optional<Customer> findByCode(String code);
执行此操作时,我得到Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING。
有没有办法从spring-data-cassandra 中避免这种情况?我不想在我的查询中添加ALLOW FILTERING。我尝试在 code 列上创建单独的索引,但这并没有解决问题。我认为它在 spring 数据配置中停止。如果我在cqlsh 中执行相同的查询,它会起作用。
【问题讨论】:
标签: spring cassandra spring-data spring-data-jpa spring-data-cassandra