我正在尝试做以下事情:
private val preparedFindQuery = session.prepare {
s"""
|SELECT hash, art_index, operating_system, height, width, resolution, orientation, brand, model, networktype, network, aggcount
|FROM $keyspace.$table
|WHERE hash = :hash
| AND art_index >= :from_art_index
| AND art_index <= :to_art_index
| ORDER BY :orderCol :order
""".stripMargin.trim
}
不幸的是我收到以下错误:
line 6:11 no viable alternative at input ':' (... <= :to_art_index ORDER BY [:]...)
com.datastax.driver.core.exceptions.SyntaxError: line 6:11 no viable alternative at input ':' (... <= :to_art_index ORDER BY [:]...)
是否有可能使这项工作成功或者无法以编程方式使用订单?提前致谢
答案 0 :(得分:3)
您不能在&#39;顺序中使用命名参数。标准因为它需要列名而不是值/绑定标记(?,:name)。您需要在部分准备好的报表中提供您希望订购数据的实际列名,并且BryceAtNetwork23提到某些列不能订购。
答案 1 :(得分:1)
您可以基于Lucene框架(只是一个库)创建一个CUSTOM INDEX,然后按照您想要的任何列进行排序,如下例所示:
SELECT * FROM tweets WHERE expr(tweets_index, '{
filter : [ {type: "range", field: "time", lower: "2014/04/25", upper: "2014/05/01"},
{type: "prefix", field: "user", value: "a"} ],
query : {type: "phrase", field: "body", value: "big data gives organizations", slop: 1},
sort : {field: "time", reverse: true}') limit 100;
在此处查找详情和示例cassandra-lucene-index