Stratio Lucene为Cassandra

问题描述:

我是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"} 
    } 
}' 
}; 

谢谢!

第一:你不能仅查看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