Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Search Value in Cassandra like 'WHERE' in SQL?
    primarykey
    data
    text
    <p>Hello fellow developers,i a bit stuck in querying in cassandra,im trying to google how to add restriction/conditioning in cassandra and got some example,so i create method like this,i using Hector for client API:</p> <pre><code> IndexedSlicesQuery&lt;String,String,String&gt; indexedSlicesQuery=new IndexedSlicesQuery&lt;String, String, String&gt;(keyspace, serializer, serializer, serializers); indexedSlicesQuery.addEqualsExpression(columnName, value); indexedSlicesQuery.setReturnKeysOnly(); indexedSlicesQuery.setColumnFamily(COLUMNFAMILY); indexedSlicesQuery.setStartKey(""); QueryResult&lt;OrderedRows&lt;String,String,String&gt;&gt; result=indexedSlicesQuery.execute(); return result; </code></pre> <p>is the method right? is the 'WHERE' like method is <code>indexedSlicesQuery.addEqualsExpression(columnName, value);</code>?</p> <p>any body can help me? i still try this out,because i got some error like this :</p> <pre><code>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) </code></pre> <p>iam sorry for my newbie question and my bad english..thanks..:D</p> <p><strong>UPDATE</strong></p> <p>OK,After Googling and googling,i found a solutions based on this <a href="http://www.datastax.com/docs/0.7/data_model/secondary_indexes" rel="nofollow">Link</a>, this technic is to create index_type when create some column family,like this (based on that link):</p> <pre><code>[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}]; </code></pre> <p>after create that indexed column family,you can query llike ordinray sql in cassandra-cli..and i would try that in hector..thanks for your attention..:D</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload