因爲我經常有說明這個問題下面我想改變,但缺乏一個更好的選擇。什麼是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