我有一个类似
的表结构 创建表文件(id文本主键,fname文本,mimetype文本,isdir boolean,位置文本);
在文件(位置)上创建索引file_location;
以下是表格中的内容:
插入文件(id,fname,mimetype,isdir,location)值('1','f1','pdf',False,'c:/ test /');
插入文件(id,fname,mimetype,isdir,location)值('2','f2','pdf',False,'c:/ test /');
插入文件(id,fname,mimetype,isdir,location)值('3','f3','pdf',False,'c:/ test /');
插入文件(id,fname,mimetype,isdir,location)值('4','f4','pdf',False,'c:/ test / a /');
我想列出符合以下条件的所有ID:
从文件中选择ID,例如'%/ test /%';
我知道CQL不支持,有人可以建议我采用这种通配符搜索查询的方法。请建议。
答案 0 :(得分:7)
DataStax Enterprise将全文搜索添加到Cassandra:http://www.datastax.com/docs/datastax_enterprise3.1/solutions/search_index
答案 1 :(得分:1)
从Cassandra 3.4开始,SASI索引可以做到这一点。这应该起作用:
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'
};
这将在“文件”列上搜索所有“%abc%”查询。 更多信息here。