【问题标题】:Stratio Lucene for CassandraCassandra 的 Stratio Lucene
【发布时间】:2017-04-21 03:17:39
【问题描述】:

我是 Lucene 的新手。刚开始。我有几个基本问​​题:

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

  • 如何删除使用 Stratio Lucene 创建的索引?

  • 有什么区别

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

输入:“字符串”并输入:“文本”

我要求区别的原因是因为我在尝试创建我的第一个 lucene 索引时遇到了错误。我在 Cassandra 中的专栏是这样的:'fld_1 text',但是当我尝试像上面那样在 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"}
  }
}'
};

谢谢!

【问题讨论】:

    标签: cassandra lucene stratio


    【解决方案1】:

    首先:您不能只查看 Stratio Lucene 索引,下面的查询将显示所有索引

    SELECT * FROM system."IndexInfo"; 
    

    第二:您可以使用DROP INDEX index_name 命令删除索引。即

    DROP INDEX test;
    

    第三:在 Stratio Lucene Index 中,string 是未分析的文本值,text 是根据指定分析器分析的语言感知文本值。

    这意味着如果您将字段指定为字符串,它将直接索引和查询。但是如果你使用文本,那么它将首先由你指定的分析器分析,默认是default_analyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) 然后索引和查询。

    编辑:

    您必须先在 cassandra 中创建一个文本字段,然后在创建索引时指定它。

    例子:

    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

    【讨论】:

    • 感谢您的回复。我用更多信息更新了这个问题。我正在按照您提到的页面上的示例进行操作。你能帮忙解释一下吗?
    • 您使用的是哪个 cassandra 和 stratio 索引版本,并放置您用于创建索引的架构
    • 我正在使用 Cassandra 3.10 和 stratio 3.10。
    • 还有架构??
    • 顺便说一句,如果您使用的是 cassandra 3.10,为什么不使用 SASIIndex docs.datastax.com/en/cql/3.3/cql/cql_using/useSASIIndex.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 2018-10-09
    • 2016-06-29
    相关资源
    最近更新 更多