Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cassandra 如何像';其中';在SQL中?_Cassandra - Fatal编程技术网

Cassandra 如何像';其中';在SQL中?

Cassandra 如何像';其中';在SQL中?,cassandra,Cassandra,各位开发人员,您好,我对cassandra中的查询有点着迷,我尝试在google上搜索如何在cassandra中添加限制/条件,并获得了一些示例,因此我创建了如下方法,我使用Hector作为客户端API: IndexedSlicesQuery<String,String,String> indexedSlicesQuery=new IndexedSlicesQuery<String, String, String>(keyspace, serializer, se

各位开发人员,您好,我对cassandra中的查询有点着迷,我尝试在google上搜索如何在cassandra中添加限制/条件,并获得了一些示例,因此我创建了如下方法,我使用Hector作为客户端API:

    IndexedSlicesQuery<String,String,String> indexedSlicesQuery=new IndexedSlicesQuery<String, String, String>(keyspace, serializer, serializer, serializers);
    indexedSlicesQuery.addEqualsExpression(columnName, value);
    indexedSlicesQuery.setReturnKeysOnly();
    indexedSlicesQuery.setColumnFamily(COLUMNFAMILY);
    indexedSlicesQuery.setStartKey("");
    QueryResult<OrderedRows<String,String,String>> result=indexedSlicesQuery.execute();

    return result;
我为我的新手问题和糟糕的英语感到抱歉谢谢

更新

好的,在谷歌搜索和谷歌搜索之后,我找到了一个基于此的解决方案,这项技术是在创建一些列族时创建索引类型,如下所示(基于该链接):


创建索引列族后,您可以在cassandra cli中查询类似ordinray sql的sql。我会在hector中尝试。感谢您的关注::D

您需要在要运行WHERE子句的列中添加索引。

您好,Zanson,感谢您的响应,我一直在cassandra cli中尝试并成功,但我在赫克托身上发现了问题。在答案部分,你可以简单地展示一下你对卡桑德拉的类似搜索的选择。它可能对所有人都有用。
1296 [main] INFO me.prettyprint.cassandra.hector.TimingLogger - start[1306744089788] time[158] tag[READ.fail_]
Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:No indexed columns present in index clause with operator EQ)
        at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
        at me.prettyprint.cassandra.service.KeyspaceServiceImpl$12.execute(KeyspaceServiceImpl.java:513)
        at me.prettyprint.cassandra.service.KeyspaceServiceImpl$12.execute(KeyspaceServiceImpl.java:495)
        at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
        at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:221)
        at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
        at me.prettyprint.cassandra.service.KeyspaceServiceImpl.getIndexedSlices(KeyspaceServiceImpl.java:517)
        at me.prettyprint.cassandra.model.IndexedSlicesQuery$1.doInKeyspace(IndexedSlicesQuery.java:140)
        at me.prettyprint.cassandra.model.IndexedSlicesQuery$1.doInKeyspace(IndexedSlicesQuery.java:131)
        at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
        at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:85)
        at me.prettyprint.cassandra.model.IndexedSlicesQuery.execute(IndexedSlicesQuery.java:130)
[default@demo] create column family users with comparator=UTF8Type
... and column_metadata=[{column_name: full_name, validation_class: UTF8Type},
... {column_name: state, validation_class: UTF8Type},
... {column_name: birth_date, validation_class: LongType, index_type: KEYS}];