【问题标题】:What are good alternatives to the Cassandra Lucene Index?Cassandra Lucene 索引有什么好的替代品?
【发布时间】:2016-01-22 04:58:51
【问题描述】:

由于我经常遇到下面描述的这个问题,我想改变但没有更好的选择。

我有 2 个查询应该返回相同的结果。但是第二个查询返回的结果要少得多,有时甚至没有结果。这是 2 个查询:

SELECT * FROM statistics WHERE source = 'toutiao' AND timespan = '3';
SELECT * FROM statistics WHERE source = 'toutiao' AND timespan = '3' AND text = '{ sort: {fields: [{field: "speed", reverse: true}]}}';.

我使用这个自定义的 cassandra 索引 https://github.com/Stratio/cassandra-lucene-index

编辑:

我使用 Cassandra 2.2.4.1 cassandra-lucene-index 2.2.4

'text' 是我建立索引的表列。

我的索引创建查询是:

CREATE CUSTOM INDEX statistics_text_idx ON toutiao.statistics (text) USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {'schema': '{
            fields : {
                title: {
                                    type : "text", analyzer : "english"},
                                    category : {type:"string"},
                    genre : {type:"string"},
                    speed  : {type : "integer",sorted : true}
            }
    }', '
            refresh_seconds': '1'};

建表查询:

DROP TABLE IF EXISTS statistics;

CREATE TABLE statistics (
source text,
timespan text,
id text,
title text,
thumbnail text,
url text,
text text,
created_at timestamp,
category text,
category2 text,
genre text,
author text,
reads int,
likes int,
comments int,
shares int,
speed int,
PRIMARY KEY (source, timespan, id)
)WITH CLUSTERING ORDER BY (timespan DESC) AND caching = '{"keys":"ALL", "rows_per_partition":"ALL"}';

这是我的数据插入程序:

cluster = Cluster(['localhost'])
session_statis = cluster.connect(keyspace)
session_statis.execute('INSERT INTO tablename(col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15) values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', (value1,value2,value3,value4,value5,value6,value7,value8,value9,value10,value11,value12,value13,value14,value15))

感谢您的帮助!

【问题讨论】:

标签: lucene cassandra


【解决方案1】:

我想我知道你做错了什么,

'text' 是您在其上构建索引的表列吗???

您可以在这里发布您的 cassandra 版本、cassandra-lucene-index 版本和您的索引创建查询吗?

(免责声明:我在 Stratio 工作:))

【讨论】:

  • 感谢您的回复。我在上面帖子的编辑部分添加了您要求的信息。如果你能帮忙就太好了!
  • 抱歉,我需要更多信息才能重现此内容。您能否在github 中打开一个带有表创建查询和一些插入的问题???
  • 我在上面添加了创建查​​询表。期待您的反馈。谢谢
  • 我还添加了数据插入程序。期待你的答复!谢谢
  • 嗨,我的意思是插入是真实的数据,试图重现这个问题。拜托,你能打开一个问题here???
【解决方案2】:

Doanduyhai 已经在你的另一个帖子中回答了这个问题,但我想我也会在这里插话。

当涉及到 Cassandra 数据的“搜索”时,您有几个选择,这取决于一些因素,例如 SLA、易用性、免费 VS。 Stratio 绝对是一个有趣的开源选项 - 不确定您的问题出在哪里,但我还没有在生产中看到它(我确定人们正在使用它,只是还没有看到它)

至于替代方案,您基本上有两种选择:

Option 1 - roll your own established Lucene based search API. 

您在此处的选择是 ElasticSearch 或 Solr。两者都有自己的优势并具有开源选项。这里的挑战是您必须管理一个单独的集群以及来自 Cassandra 的 ETL 数据或双写。在这种情况下,您有更多的灵活性,因为如果您有许多系统,这可以充当通用搜索集群。这确实意味着您自己管理了故障场景(例如脑裂问题),并且您失去了 CQL 中的 Lucene 集成。

Option 2 - Go the enterprise route (disclaimer: I work for DataStax)

DataStax Enterprise 有一个非常好的集成搜索选项。 Solr 与 Cassandra 共享相同的 JVM,它允许 Cassandra 数据立即被索引并利用 Cassandra 的可用性。还有一些很酷的查询路由恰好可以提高搜索效率。请参阅:DSE Search。这显然是一个付费选项——尽管可以在开发中免费使用。

【讨论】:

    【解决方案3】:

    为了快速测试您的查询,添加 Kibana,它是 ELK 堆栈的一部分,它将生成您尝试完成的功能,并生成满足您要求的 elasticsearch/Lucene 代码。你的 es 需要匹配你下载的任何 Kibana 版本:对于 2015 年 12 月最新版本的 Kibana,我必须从 es 2 升级到 2.1 以匹配当前的 Kibana。由于 es 现在是 2.2 的版本,Kibana 可能也升级了。啊...刚刚为您检查过... Kibana 4.4 需要 es 2.2...所以推出速度很快。

    https://www.elastic.co/downloads/kibana

    披露:我的主要是 gptext、madlib 和 plr,但我喜欢 es.....:) gptext 会更像 SQL ......类似于你上面的......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-27
      • 2023-03-08
      • 1970-01-01
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多