为什么我的Cassandra Lucene Index从2个查询返回的结果较少/没有结果?

时间:2016-02-02 03:38:18

标签: cassandra lucene

由于我经常遇到下面描述的这个问题,我想改变但缺乏更好的替代方案。

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

感谢您的帮助!

0 个答案:

没有答案
相关问题