因为我经常有说明这个问题下面我想改变,但缺乏一个更好的选择。什么是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))
感谢您的帮助!
问题在这里回答(替代Stratio索引):http://stackoverflow.com/questions/34938494/why-does-my-cassandra-lucene-index-not-return-all-results – doanduyhai