我有一个表格结构
创建表文件(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不支持,任何人都可以建议我采用这种通配符搜索查询的方法。请建议。
DataStax Enterprise将全文搜索添加到Cassandra:http://www.datastax.com/docs/datastax_enterprise3.1/solutions/search_index
从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。