【问题标题】:Nutch 2.3 + Elasticsearch 2.1.1. Cannot load Elasticsearch dependenciesNutch 2.3 + Elasticsearch 2.1.1。无法加载 Elasticsearch 依赖项
【发布时间】:2016-04-01 06:08:52
【问题描述】:

我正在尝试集成 Nutch 2.3,以便将数据推送到最新的 Elasticsearch 2.1.1。 我开始更新以下文件中的版本和依赖项:

indexer-elastic/plugin.xml

    <plugin id="indexer-elastic" name="ElasticIndexWriter" version="1.0.0"
  provider-name="nutch.apache.org">

  <runtime>
    <library name="indexer-elastic.jar">
      <export name="*" />
    </library>

    <library name="elasticsearch-2.1.1.jar"/>

    <library name="hppc-0.7.1.jar"/>
    <library name="jackson-core-2.6.2.jar"/>
    <library name="jackson-dataformat-cbor-2.6.2.jar"/>
    <library name="jackson-dataformat-smile-2.6.2.jar"/>
    <library name="jackson-dataformat-yaml-2.6.2.jar"/>
    <library name="guava-18.0.jar"/>
    <library name="compress-lzf-1.0.2.jar"/>
    <library name="t-digest-3.0.jar"/>
    <library name="jsr166e-1.1.0.jar"/>
    <library name="commons-cli-1.3.1.jar"/>
    <library name="netty-3.10.5.Final.jar"/>
    <library name="joda-time-2.8.2.jar"/>

    <library name="lucene-analyzers-common-5.3.1.jar"/>
    <library name="lucene-backward-codecs-5.3.1.jar"/>
    <library name="lucene-core-5.3.1.jar"/>
    <library name="lucene-highlighter-5.3.1.jar"/>
    <library name="lucene-join-5.3.1.jar"/>
    <library name="lucene-memory-5.3.1.jar"/>
    <library name="lucene-queries-5.3.1.jar"/>
    <library name="lucene-queryparser-5.3.1.jar"/>
    <library name="lucene-spatial-5.3.1.jar"/>
    <library name="lucene-suggest-5.3.1.jar"/>

    <library name="HdrHistogram-2.1.6.jar"/>
    <library name="joda-convert-1.2.jar"/>
  </runtime>

  <requires>
    <import plugin="nutch-extensionpoints" />
  </requires>

  <extension id="org.apache.nutch.indexer.elastic"
    name="Elasticsearch Index Writer"
    point="org.apache.nutch.indexer.IndexWriter">
    <implementation id="ElasticIndexWriter"
      class="org.apache.nutch.indexwriter.elastic.ElasticIndexWriter" />
  </extension>

</plugin>

indexer-elastic/ivy.xml

<ivy-module version="1.0">
  <info organisation="org.apache.nutch" module="${ant.project.name}">
    <license name="Apache 2.0" />
    <ivyauthor name="Apache Nutch Team" url="http://nutch.apache.org" />
    <description>Apache Nutch</description>
  </info>

  <configurations>
    <include file="../../..//ivy/ivy-configurations.xml" />
  </configurations>

  <publications>
    <!--get the artifact from our module name -->
    <artifact conf="master" />
  </publications>

  <dependencies>
    <dependency org="org.elasticsearch" name="elasticsearch"
      rev="2.1.1" conf="*->default" />

    <dependency org="com.google.guava" name="guava" rev="18.0" />
  </dependencies>
</ivy-module>

我还重新设计了 org.apache.nutch.indexwriter.elastic.ElasticIndexWriter 以适用于 elasticsearch 2.1.1 客户端的新界面。

那么问题出在哪里?

indexer-elastic/plugin.xml 中列出的依赖项似乎不会在运行时自动加载。因此,elasticsearch 客户端无法从中受益并抛出异常。 因此,我尝试了一种不同的方法,根据它在 $NUTCH_ROOT/ivy/ivy.xml 中列出的 Apache Nutch 的主要依赖项给我的异常,逐个添加依赖项。这不是正确的方法,但它确实有效。

  1. 如何处理插件依赖?
  2. 在插件中使用较新版本的库的策略是什么。例如 Nutch 使用 Guava v11.0.2,但 Elasticsearch 2.1.1 需要 Guava v18.0。虽然我在 indexer-elastic/ivy.xml 中明确指定了它,但它似乎在运行时加载了旧版本。

【问题讨论】:

  • 是否同时运行 Nutch 2.3 并索引 Elasticsearch 2.x?
  • 嗯,是的,我最终设法让它工作。我可以在几天内将它推送到 github。我会告诉你的。
  • 也许这个 PR 对于正在寻找 Elasticsearch 2.x 实现的其他人来说也很有趣:github.com/apache/nutch/pull/96

标签: apache elasticsearch ant ivy nutch


【解决方案1】:

插件依赖项应该在插件的 ivy.xml 和 plugin.xml 文件中声明。我没有测试您包含的文件,但看不出它们有什么问题。正如您所指出的,在主 ivy 文件中声明 deps 并不好。

this note on how to upgrade the Tika plugin,同样的逻辑适用于所有插件。

至于解决主要依赖项与插件依赖项之间的冲突,不幸的是,您必须自己处理它,例如在主 ivy.xml 中强制您需要的版本,因为 Nutch 不会将插件作为主代码的依赖项(在 Maven 意义上)处理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-10
    • 2015-01-02
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    • 2016-06-13
    相关资源
    最近更新 更多