2016-06-01 22 views
0

這裏是我的查詢:卡桑德拉Stratio無法執行讀取

select * from profiles where expr(profiles_index, '{ 
    filter: { 
    type: "date_range", 
    field: "age", 
    from: "1984/01/01", 
    to: "2010/01/01", 
    operation: "is_within" 
    } 
}'); 

這裏是我的表:

CREATE TABLE profiles (
    user_id timeuuid, 
    age timestamp, 
    PRIMARY KEY (user_id) 
); 

和我的架構看起來是這樣的:

CREATE CUSTOM INDEX profiles_index ON profiles() 
USING 'com.stratio.cassandra.lucene.Index' 
WITH OPTIONS = { 
    'refresh_seconds' : '60', 
    'schema' : '{ 
     default_analyzer : "english", 
     fields : { 
      age     : {type : "date", 
            validated : true, 
            pattern : "yyyy/MM/dd" 
      } 
     } 
    }' 
}; 

我得到這個例外:

回溯(最近一次調用最後一次):文件 「/opt/apache-cassandra-3.0.3/bin/cqlsh.py」,第1249行,在 執行簡單語句 result = future.result()文件「/ opt /apache-cassandra-3.0.3/bin/../lib/cassandra-driver-internal-only-3.0.0-6af642d.zip/cassandra-driver-3.0.0-6af642d/cassandra/cluster.py「, 第3122行,結果爲 raise self._inalifeception ReadFailure:code = 1300 [副本未能執行讀取] message =「操作失敗 - 收到0 響應和1次失敗」info = {'failures':1,'received_responses ': 0,'required_responses':1,'consistency':'ONE'}

有誰知道爲什麼我可能會得到這個錯誤?

回答

1

我需要使用「範圍」搜索,而不是「日期範圍」搜索。如果您使用「日期範圍」搜索,則最好使用「日期範圍映射器」。

2

@ user1019182是完全正確的,「date_range」搜索旨在與「date_range」映射器索引的數據一起使用,該映射使用空間方法索引由開始和結束日期組成的持續時間。

對於你應該使用「範圍」搜索持續時間內搜索簡單日期:

select * from profiles where expr(profiles_index, '{ 
    filter: { 
    type: "range", 
    field: "age", 
    lower: "1984/01/01", 
    upper: "2010/01/01", 
    include_lower: true, 
    include_upper:true 
    } 
}'); 

@馬亨德拉 - 辛格是錯誤的,cqlsh默認的時間戳不會與此有關。