Search Cassandra CQL Template

I have a table structure like

create a table file (primary key of text id, text fname, text mimetype, isdir boolean, location text);
create the file_location index in the file (location);

and then the contents in the table:

insert into the file (id, fname, mimetype, isdir, location) values ​​('1', 'f1', 'pdf', False, 'c: / test /'); insert into the files (id, fname, mimetype, isdir, location) values ​​('2', 'f2', 'pdf', False, 'c: / test /'); insert into the files (id, fname, mimetype, isdir, location) values ​​('3', 'f3', 'pdf', False, 'c: / test /'); insert values ​​('4', 'f4', 'pdf', False, 'c: / test / a /') into the files (id, fname, mimetype, isdir, location);

I want to list all identifiers that match the following criteria:

select id from the file where "% / test /%" is located;

I know that, as it is not supported in CQL, can someone suggest an approach that I should use for such wildcard search queries. Please suggest.

+4
source share
2 answers
+6
source

Starting with Cassandra 3.4, this is possible with SASI indexes. This should work:

CREATE CUSTOM INDEX string_search_idx ON file(location) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 'tokenization_enable_stemming': 'true', 'tokenization_locale': 'en', 'tokenization_skip_stop_words': 'true', 'analyzed': 'true', 'tokenization_normalize_lowercase': 'true' }; 

This should find all queries "% abc%" in the file column. More info here .

0
source

Source: https://habr.com/ru/post/1498957/


All Articles