2016-01-22 75 views
0

因为我经常有说明这个问题下面我想改变,但缺乏一个更好的选择。什么是Cassandra Lucene索引的不错替代方案?

我有两个疑问,应返回相同的结果。但是第二个查询返回的结果要少得多,有时候没有结果。这是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}]}}';. 

我用这个自定义卡桑德拉指数https://github.com/Stratio/cassandra-lucene-index

编辑:

我用卡桑德拉2.2.4.1卡桑德拉-的Lucene索引2.2.4

'文本' 是在我已经建立了索引的表列。

我创建索引的查询是:

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)) 

感谢您的帮助!

+1

问题在这里回答(替代Stratio索引):http://stackoverflow.com/questions/34938494/why-does-my-cassandra-lucene-index-not-return-all-results – doanduyhai

回答

1

Doanduyhai已经回答了这个在您的其他线程,但我想我会附和这里。

当涉及到“搜索”的卡桑德拉的数据,你有几种选择,它依赖于一些东西,如SLA的,易于使用的,免费VS.支付等Stratio绝对是一个有趣的开源选项 - 不知道从哪里你的问题,从干,但我还没有看到它在生产中(我敢肯定,人们都在使用它,只是还没有看到它)

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

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

您在这里的选择是ElasticSearch或Solr。两者都提供他们自己的优势并拥有开源选项。这里的挑战是,你将不得不管理一个单独的集群和卡桑德拉或双写任何ETL数据。在这种情况下,您有更多的灵活性,因为如果您有很多系统,这可以充当通用搜索群集。这并不意味着你必须管理的故障情况自己(如脑裂问题),你失去的CQL Lucene的集成。

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

DataStax Enterprise具有相当不错的集成搜索选项。 Solr的共享相同的JVM卡桑德拉其允许卡桑德拉数据立即被编入索引并利用卡桑德拉可用性优势。还有,恰好使搜索更高效一些很酷的查询路由。参见:DSE Search。这显然是一个支付选项 - 虽然自由开发使用。

I lied, there is an option 3 - Build your own Lucene based search solution :) 

这个选项显然是耗时和资源密集型的大部分时间,但如果你成功了,你会得到所有的女人,酒和钱,你所能想。也许。

4

我想我知道你在做什么不好,

是“文”在你所建索引的表列???

你能在这里发表你的cassandra版本,cassandra-lucene-index版本和你的索引创建查询吗?

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

+0

谢谢你的回复。我在上面的帖子中的编辑部分添加了您请求的信息。如果你能帮忙,会很棒! – peter

+2

对不起,但我需要更多的信息才能够重现这一点。你可以请[github](https://github.com/Stratio/cassandra-lucene-index/issues)与表创建查询和一些插入打开一个问题? –

+0

我添加了上面的创建查询表。期待您的反馈。谢谢 – peter

1

您所查询的快速检测,添加Kibana,麋鹿堆栈会产生你要完成的功能的一部分,并生成elasticsearch /符合你的要求的Lucene代码。你的es需要匹配你所下载的任何Kibana版本:2015年12月的Kibana最新版本,我必须从es2到2.1来匹配当前的Kibana。由于es现在有2.2的味道,Kibana也可能升级。啊...只是检查了你...... Kibana在4.4需要es 2.2 ...所以推出发生得很快。

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

披露:我主要是gptext,马德利布和PLR,但我喜欢上课...... :) gptext会更类似于SQL的......类似你有什么...以上