【问题标题】:how to query on cassandra table using custom index in select clause如何在选择子句中使用自定义索引查询 cassandra 表
【发布时间】:2015-04-21 18:00:19
【问题描述】:

我有一个由 solr 在 cassandra 表上创建的自定义索引

CREATE CUSTOM INDEX custom_index ON table_name (column) USING 'com.datastax.bdp.search.solr.Cql3SolrSecondaryIndex';

据我所知,在cassandra的select子句中,select查询只能在where子句中有主键。

我可以在 where 子句中使用这个自定义索引吗?

【问题讨论】:

    标签: solr cassandra cql datastax


    【解决方案1】:

    为了根据您的 lucene-solr 索引运行 CQL 查询,您必须安装 DataStax Enterprise 4.6 并使用“solr_query”特殊列,如下所述:http://www.datastax.com/documentation/datastax_enterprise/4.6/datastax_enterprise/srch/srchCql.html

    【讨论】:

    • 非常感谢。我注意到我们必须进行类似 WHERE solr_query='name: cat name: dog -name:fish' 的查询。在 = 'XXX' 的地方我还有其他方法可以做吗?
    【解决方案2】:

    是的,你可以。您可以在 where 子句中使用分区键和索引。但是如果你想使用没有分区键的索引列,你必须指定 ALLOW FILTERING (见下面的例子)

    SELECT * FROM <myColumnFamilly> WHERE <column> > 100 ALLOW FILTERING;
    

    当然在这个例子中必须是数字类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-29
      • 1970-01-01
      • 2013-10-23
      相关资源
      最近更新 更多