你好的開發夥伴們,IA位卡在卡珊德拉查詢,即時試圖谷歌如何在卡桑德拉加限制/調節並得到了一些例子,所以我創建的方法是這樣的,我用赫克託客戶端API:如何在Cassandra中像'WHERE'一樣在SQL中搜索值?
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;
是正確的方法? 是'WHERE'的方法是indexedSlicesQuery.addEqualsExpression(columnName, value);
?
任何機構都可以幫助我嗎? 我仍然嘗試了這一點,因爲我得到了一些錯誤是這樣的:
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)
IAM對不起我的新手問題,我不好english..thanks ..:d
UPDATE
好的,谷歌搜索和谷歌搜索後,我發現了一個基於這個解決方案Link,這個技術是創建index_type時創建一些列家庭,像這樣(基於該鏈接):
[[email protected]] 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}];
後創建的索引列的家庭,可以在卡桑德拉 - cli..and llike ordinray SQL查詢我會嘗試在hector..thanks的關注..:d
你可以在答案部分簡要地顯示你的搜索喜歡cassandra選項。它可能對所有人都有用。 – BobDroid 2012-04-02 05:21:11