【问题标题】:Cassandra CQL wildcard searchCassandra CQL 通配符搜索
【发布时间】:2013-08-28 23:15:00
【问题描述】:

我有一个像

这样的表结构

创建表文件(id 文本主键、fname 文本、mimetype 文本、isdir 布尔值、位置文本);
在文件(位置)上创建索引文件位置;

以下是表格中的内容:

插入文件(id、fname、mimetype、isdir、位置)值('1'、'f1'、'pdf'、False、'c:/test/');
插入文件 (id, fname, mimetype, isdir, location) values('2', 'f2', 'pdf', False, 'c:/test/');
插入文件 (id, fname, mimetype, isdir, location) values('3', 'f3', 'pdf', False, 'c:/test/');
插入文件 (id, fname, mimetype, isdir, location) values('4', 'f4', 'pdf', False, 'c:/test/a/');

我想列出所有符合以下条件的 id:

从文件中选择 id,位置如 '%/test/%';

我知道在 CQL 中不支持 like,任何人都可以建议我应该对这些通配符搜索查询采取的方法。请提出建议。

【问题讨论】:

    标签: cassandra cql cql3


    【解决方案1】:

    DataStax Enterprise 为 Cassandra 添加全文搜索:http://www.datastax.com/docs/datastax_enterprise3.1/solutions/search_index

    【讨论】:

    • DataStax 有没有替代品。它似乎没有适用于 windows 的版本。我主要是找DSE Search。
    【解决方案2】:

    从 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.

    【讨论】:

    • 请注意,SASI 索引几乎无人维护,因此在 C* 4.0 中它们将默认禁用,要启用它们,您需要更改 cassandra.yaml...
    猜你喜欢
    • 2012-07-25
    • 2021-10-03
    • 2014-12-06
    • 1970-01-01
    • 2019-09-25
    • 2016-03-16
    • 2012-08-29
    • 2015-03-15
    • 2018-04-20
    相关资源
    最近更新 更多