question

Jesver avatar image
Jesver asked Erick Ramirez edited

How can I search by character ordered by value?

search by character ordered by value Cassandra:

I am currently in the process of mastering cassandra with a first project. This one is a social network. I am working on the search bar to find users in the network. I'm looking for the best db organization as well as the best cql command to retrieve a list of 5 users starting from a score (float by descending order) as well as the first character of the pseudo of this one that the user entered. Here is my idea to organize the cassandra table

CREATE TABLE user_classement (id int, user_name set<text>, score float,PRIMARY KEY(id, score))WITH CLUSTERING ORDER BY (score DESC) ;

create index on user_classement (user_name);

Here is my idea to organize the cassandra table

INSERT INTO user_classement(id, user_name, score) VALUES (678, {'j', 'je', 'jes', 'jesv', 'jesve'}, 89,6);

The problem is that this organisation is not at all optimised and does not work with a contains in the cql command

search
1 comment
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

smadhavan avatar image smadhavan ♦ commented ·
@Jesver, like Erick mentioned, enterprise search functionality can be served by softwares such as Apache Solr or ElasticSearch or you could try DataStax Enteprise (DSE) Search.
0 Likes 0 ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

You have a use case that requires complex text searching that is quite common but is not natively supported in Cassandra.

Cassandra is optimised for super-fast retrieval of a row (or rows) within a single partition. Doing complex searches is a slightly different access pattern compared to the way partitions (and rows they contain) are organised on disk.

Most use purpose-built complex text search software such as Apache Solr or Elasticsearch. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.