【问题标题】:Elasticsearch and luke弹性搜索和卢克
【发布时间】:2014-08-05 15:48:12
【问题描述】:

如何使用 luke 打开 elasticsearch 索引?

我尝试了从 3.5 到 4.8 的 luke,使用 elasticsearch 1.1 到 1.2,但似乎没有任何效果。

似乎唯一适用的资源是http://rosssimpson.com/blog/2014/05/06/using-luke-with-elasticsearch/,但不幸的是它不起作用。

【问题讨论】:

    标签: java lucene elasticsearch luke


    【解决方案1】:

    我没有尝试过任何其他版本,但它似乎适用于 luke 4.9 和 elasticsearch 版本 1.3.1(ElasticSearch 1.3.x 在下面使用 Lucene 4.9)

    在命令行执行:

    git clone https://github.com/DmitryKey/luke.git
    

    或者直接下载 luke-4.9.0 版本的源代码。 接下来,编辑 pom.xml 文件并添加以下依赖项:

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>1.3.1</version>
    </dependency>
    

    在命令行再次执行:

    cd luke
    mvn install
    

    这应该创建一个目标目录,其中包含一个名为 luke-with-deps.jar 的文件。 在任何存档管理器中打开此文件并编辑文件 META-INF/services/org.apache.lucene.codecs.PostingsFormat,如http://rosssimpson.com/blog/2014/05/06/using-luke-with-elasticsearch/ 所述,并添加以下行

    org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat
    org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat
    org.elasticsearch.search.suggest.completion.Completion090PostingsFormat
    

    保存它,您应该可以使用 luke.batluke.sh 运行 luke。 例如,现在您可以在 /indexname/0/index/ 打开索引。 如果您的 elasticsearch 集群中有多个分片(默认为 5 个),您可能无法看到该集群中的所有文档,而只能看到其中的一部分。只有 index.number_of_shards 设置为 1 时,您应该能够看到所有文档。

    【讨论】:

      【解决方案2】:

      我已成功打开 ElasticSearch 1.3.4 的索引(它使用 Lucene 4.9.1 引擎盖)。我也按照Ross Simpson's blog 中的说明进行操作,但没有奏效。正如他所说,我在pom.xml 中添加了 ElasticSearch 依赖项(在我的情况下为 1.3.4 版):

      <dependency>
          <groupId>org.elasticsearch</groupId>
          <artifactId>elasticsearch</artifactId>
          <version>1.3.4</version>
      </dependency>
      

      并且还在pom.xml中设置Lucene版本(在我的例子中是4.9.1):

      <lucene.version>4.9.1</lucene.version>
      

      我将 jar 中的META-INF/services/org.apache.lucene.codecs.PostingsFormat 更新如下:

      org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
      org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat
      org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat
      org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat
      org.elasticsearch.search.suggest.completion.Completion090PostingsFormat
      

      到目前为止,说明与博客文章中的说明相同。我采取的额外步骤是更新META-INF/services/org.apache.lucene.codecs.Codec 添加最后一行(打开索引时出现异常,未找到名为 Lucene49 的编解码器):

      org.apache.lucene.codecs.simpletext.SimpleTextCodec
      org.apache.lucene.codecs.appending.AppendingCodec
      org.apache.lucene.codecs.lucene49.Lucene49Codec
      

      【讨论】:

        【解决方案3】:

        Luke 现在支持 elasticsearch 1.5.0:https://github.com/DmitryKey/luke(从 master 构建或使用 https://github.com/DmitryKey/luke/releases/tag/luke-4.10.4-field-reconstruction)。

        【讨论】:

          猜你喜欢
          • 2012-09-10
          • 1970-01-01
          • 2021-11-23
          • 2013-09-16
          • 1970-01-01
          • 1970-01-01
          • 2018-10-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多