How to Search In cassandra? - search

i wanna to search in cassandra database.
After much research, I found
Stratio’s Cassandra Lucene Index
Is there another way to simple search on Cassandra?
I mean a simple search query something like in Mysql
I've used this query but his conclusion was wrong
select * from users where uname > 'sa' allow filtering;

It seems to me that you'd want to perform a text search on a non PRIMARY KEY column.
If that's the case, you could use a SSTable Attached Secondary Index (SASI) that would allow to exactly search as you wrote. Specifically, you'd need to create a CONTAINS index to perform inequality searches on text fields. You need Cassandra 3.4 and later.

Related

cassandra where clause, one field from udt

How can I query based on only one field in UDT (Cassandra) ?
I have a UDT which contains marital status and I need data for all the married people
but when I query based on one field it gives empty output
How can I do this ?
short answer - NO, at least not in the stock Cassandra. It's possible to do using the DSE Search, but it adds its own constraints. Maybe when SAI will be implemented some day, it will support indexing of UDT fields. I don't remember if SASI supports this, but it's really not recommended to use. But even if indexing was supported, it's still bad case (maybe except SAI) for Cassandra because it will create big partitions to represent each status.
The general rule is that you need to always query by partition key, with possibility to use secondary indexes when you need to search for another field, but only inside partition. If you need to query by multiple fields that not primary keys, I would suggest to take another database, or use Elasticsearch/Solr (although they aren't very good in geo-distributed environment).

Cassandra implementing string search pattern

Does Cassandra support like attribute on a string. I feel like based on partition system in cassandra, this type of query is not even supported in cassandra.
If I have model post
CREATE TABLE Post (
title text PRIMARY KEY,
description text,
);
How can I search title and description for a particular string pattern.?
what are options to implement this in cassandra.?
Do I need to pull all key strings using some text analytics API from title and description and store separately in a different table ?
You're right, wildcard searches are not supported in Cassandra, given its key-value structure. A common solution people used is to use another product like Solr or Elastisearch to create indexes off of your Cassandra data.
Cassandra 3.4 and later includes support for a new type of indexing that will allow you to do partial matching and full text search. Details can be found in the DataStax documentation: Using a SSTable Attached Secondary Index (SASI).

full text search in databases

I have two fairly general question about full text search in a database. I was looking into elastic search and solr and it seems to me that one needs to produce separate documents made up of table entries, which then get searched. So the result of such a search is not actually a database entry? Or did I misunderstand something?
I also looked into whoosh search, which does index table columns and the result of whoosh are actual table rows.
When using solr or elastic search, should I put the row id into the document which gets searched and after I have my result use that id to retrieve the relevant rows from the table? Or is there a better solution?
Another question I have is if I have a id like abc/123.64664, which is stored as a string, is there any advantage in searching such a column with a FTS? It seems to me there is not much to be gained by indexing? Or am I wrong?
thanks
Elasticsearch can store the indexed document, and you can retrieve it as a part of query result. Usually ppl still store the original data in an usual DB, it gives you more reliability and flexibility on reindexing. Mind that ES indexes non-relational data. You can have you data stored in relational manner and compose denormalized documents for indexing.
As for "abc/123.64664" you can index it as tokenized string or you can tune the index for prefix search etc. It's up to you
(TL;DR) Don't think about what your data is structured in your RDBS. Think about what you are searching.
Content storage for good full text search is quite different from relational database standard storage. So, your data going into Search Engine can end up looking quite differently from the way you stored it.
This is all driven by your expected search results. You may increase granularity of the data or - opposite - denormalize it so the parent/related record content shows up in the records you actually want returned as part of search. Text processing (copyField, tokenization, pre-processing, etc) is also where a lot of content modifications happen to make a record findable.
Sometimes, relational databases support full-text search. PostgreSQL is getting better and better at that. But most of the time, relational databases just do not provide enough flexibility to support good relevancy-driven search.
Finally, if the original schema is quite complex, it may make sense to only use search engine to get the right - relevant - IDs out and then merge them in the client code with the details from the original database records.

Cassandra row key starts with [duplicate]

I have a cassandra column family which has a row key like
2012-09-30-05-42-00:30:5856869
I need to query some thing like
select * from cf where key like %5856869%
Currently I am using Astyanax , is same possible in astyanax. If not, which implementation would support it.
LIKE queries are not supported in Cassandra. If you want to query based on part of a key, you'll want to use composite keys. But in this specific case, the 5856869 portion of the key would have to be the first part for you to do what you want. Remember that with Cassandra, you must write your data the way you expect to read it.
None.... you need to write index manually - this is how you handle such things in Cassandra, or you might try full text search: Cassandra full text search like

Searching for data in Cassandra

I understand that with Cassandra, it is possible to search using secondary indexes, but the problem is I am trying to search on information from a super column. So I want to search on a value within a super column, but return everything within that row (not just that one super column).Is this possible to do?
My understanding is that Facebook and Twitter use Cassandra, and so it would seem quite pointless if they have search facilities but it is not possible to search using something built into Cassandra.
Please correct me if I have not understood the proper use of super columns within Cassandra.
Thanks.
You cannot search on a super column value, as secondary indexes are not supported for SCs. You should avoid using super columns for a variety of reasons, but mostly because they are effectively deprecated. Most super column use cases are supported through the use of composites--which will ultimately replace SCs. In the meantime, if you must search for a value in a SC, you will have to do so manually (i.e. in code) or using an external tool such as Hadoop or Solr.

Resources