2017-04-20 31 views
0

我是Lucene的新手。剛剛開始。我有幾個基本問​​題:Stratio Lucene爲Cassandra

  • 如何查看使用Stratio Lucene創建的所有索引?

  • 如何刪除使用Stratio Lucene創建的索引?

  • 是什麼

    fields: { 
        fld_1: {type: "string"}, 
        fld_2: {type: "text"} 
    } 
    

類型之間的區別:「字符串」,然後鍵入:「文本」

我之所以要求不同的是,因爲我跑的錯誤當試圖創建我的第一個lucene索引。我在卡桑德拉列是這樣的:「fld_1文本」,但是當我試圖創建和fld_1指數像上面它拋出一個異常

ConfigurationException: 'schema' is invalid : Unparseable JSON schema: Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name 
at [Source: { 
fields: { 

Lucene索引腳本:

CREATE CUSTOM INDEX lucene_index ON testTable() 
USING 'com.stratio.cassandra.lucene.Index' 
WITH OPTIONS = { 
    'refresh_seconds': '1', 
    'schema': '{ 
fields: { 
    fld_1: {type: "string"}, 
    fld_2: {type: "string"}, 
    id: {type: "integer"}, 
    test_timestamp: {type: "date", pattern: "yyyy/MM/dd HH:mm:ss"} 
    } 
}' 
}; 

謝謝!

回答

1

第一:你不能僅查看Stratio Lucene索引,查詢下面會告訴你所有的索引

SELECT * FROM system."IndexInfo"; 

二:你可以用DROP INDEX index_name命令刪除索引。即

DROP INDEX test; 

三:在Stratio Lucene索引,字符串是一個無法分析的文本值和文本是根據特定分析器分析了語言識別文本值。

這意味着如果您指定一個字段作爲字符串,它將直接索引和查詢。但是如果你使用文本,那麼它將首先由你指定的分析器進行分析,默認是default_analyzerorg.apache.lucene.analysis.standard.StandardAnalyzer)然後索引和查詢。

編輯:

你必須首先創建卡桑德拉文本字段然後創建索引時指定它。

例子:

ALTER TABLE testtable ADD lucene text; 

CREATE CUSTOM INDEX lucene_index ON testTable (lucene) USING 'com.stratio.cassandra.lucene.Index' 
WITH OPTIONS = { 
    'refresh_seconds': '1', 
    'schema': '{ 
    fields: { 
     fld_1: {type: "string"}, 
     fld_2: {type: "string"}, 
     id: {type: "integer"}, 
     test_timestamp: {type: "date", pattern: "yyyy/MM/dd HH:mm:ss"} 
    } 
    }' 
}; 

更多:https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.13/doc/documentation.rst#text-mapper

+0

感謝您回覆。我用更多的信息更新了這個問題。我在您提到的頁面上查看示例。你能幫忙解釋一下嗎? – user1860447

+0

您正在使用哪種cassandra和stratio索引版本,並將您正在使用的模式創建索引 –

+0

我正在使用Cassandra 3.10和3.10版。 – user1860447