strapdata / elassandra

Elassandra = Elasticsearch + Apache Cassandra
http://www.elassandra.io
Apache License 2.0
1.72k stars 199 forks source link

How to execute cassandra query using where clause. #41

Closed MadhuriPatil89 closed 8 years ago

MadhuriPatil89 commented 8 years ago

Hi,

I am trying to execute the select query using the where clause on the user_name field. CREATE TABLE insta2.tbl_jobseeker ( id int PRIMARY KEY, user_name text ) WITH bloom_filter_fp_chance = 0.01 AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}' AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'} AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99.0PERCENTILE'; CREATE INDEX username ON insta2.tbl_jobseeker (user_name);

But it is throwing the exception as: Traceback (most recent call last): File "/usr/local/bin/cqlsh", line 1258, in perform_simple_statement result = future.result() File "cassandra/cluster.py", line 3629, in cassandra.cluster.ResponseFuture.result (cassandra/cluster.c:69380) raise self._final_exception ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures" info={'failures': 1, 'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}

vroyer commented 8 years ago

Hi,

With CQL, you cannot use a WHERE clause to search in your cassandra table. You should use the elasticsearch API https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html#docs or the JDBC driver for elasticsearch sql4es.

Thanks.

MadhuriPatil89 commented 8 years ago

Hi,

Thanks for the reply. Can we create the cassandra index instead of elasticsearch index on the user_name so that I can perform the simple CQL query ?

vroyer commented 8 years ago

Hi, Yes, you should be able to do it for a column indexed with a cassandra index, but i just found a bug in elassandra by checking it. It is fixed and i will release a new version Thursday. Thanks for your request. Vincent.

MadhuriPatil89 commented 8 years ago

Hi, Thanks.Will wait for the Thursday release.

vroyer commented 8 years ago

Fixed with release 2.1.1-16.