Nutch 未使用 Mongodb 正确索引 Elasticsearch

Nutch does not Index on Elasticsearch correctly using Mongodb

我是 运行 Nutch 2.3.1、Mongodb 3.2.9 和 Elasticsearch 2.4.1。我遵循了本教程的混合:

https://qbox.io/blog/scraping-the-web-with-nutch-for-elasticsearch

和本教程:

http://www.aossama.com/search-engine-with-apache-nutch-mongodb-and-elasticsearch/

为了使用上述3个软件创建网络爬虫工具。

一切都很好,直到它归结为索引......只要我使用 nutch 的 index 命令:

# bin/nutch index elasticsearch -all

发生这种情况:

IndexingJob: starting
Active IndexWriters :
ElasticIndexWriter
        elastic.cluster : elastic prefix cluster
        elastic.host : hostname
        elastic.port : port (default 9300)
        elastic.index : elastic index command
        elastic.max.bulk.docs : ealstic bulk index doc counts. (default 250)
        elastic.max.bulk.size : elastic bulk index length. (default 2500500 ~2.5MB)

IndexingJob: done.

我的疯子-site.xml:

<configuration>
  <property>
    <name>storage.data.store.class</name>
    <value>org.apache.gora.mongodb.store.MongoStore</value>
    <description>Default class for storing data</description>
  </property>
  <property>
    <name>http.agent.name</name>
    <value>AOssama Crawler</value>
  </property>

  <property>
    <name>plugin.includes</name>
    <value>protocol-(http|httpclient)|urlfilter-regex|index-(basic|more)|query-(basic|site|url|lang)|indexer-elastic|nutch-extensionpoints|parse-(text|html|msexcel|msword|mspowerpoint|pdf)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)|parse-(html|tika|metatags)|index-(basic|anchor|more|metadata)</value>
  </property>
  <property>
    <name>elastic.host</name>
    <value>localhost</value>
  </property>

  <property>
    <name>elastic.cluster</name>
    <value>aossama</value>
  </property>

  <property>
    <name>elastic.index</name>
    <value>nutch</value>
  </property>

  <property>
    <name>parser.character.encoding.default</name>
    <value>utf-8</value>
  </property>

  <property>
    <name>http.content.limit</name>
    <value>6553600</value>
  </property>
</configuration>

我还查看了 ElasticIndexWriter.java 代码并注意到在第 250 行附近 class 调用了 ElasticIndexWriter。我现在正在进一步研究,但我完全不知道为什么这不适用于 Mongo。我即将放弃并尝试使用 Hbase,尽管我不喜欢它。

谢谢!

在经历了很多麻烦之后,我让它工作了。我最终使用了 ES 1.4.4、nutch 2.3.1、mongodb 3.10 和 JDK 8。

我遇到的许多问题在许多其他主题中仍未得到解答:

  • (这很简单,但是...)确保一切正常 运行。制作 确保 elasticsearch 在正确的机器上 运行ning 正确的端口。确保你可以和它交谈。确保 MongoDB 已启动 并 运行ning 在正确的端口上,确保您可以与其通信。
  • 使用正确的索引命令。对于 Nutch 3.2.1,它是: ./bin/nutch index -all(在你获取和解析之后)。如果你 运行 遇到 solr 错误,你的 nutch-site.xml 中没有正确的索引函数。
  • 在 elasticsearch.yml 和 nutch-site.xml 中将您的爬虫引擎命名为相同的名称。这是巨大的。这是我在索引函数中抛出任何错误的主要原因。
  • 版本控制。我尝试使用较新版本的 Elasticsearch 来执行此操作,但经常 运行 遇到问题。我将尝试在最新版本的 Elasticsearch 和 Mongo 上构建它,然后回到这个线程。尝试使用我第一次使用的相同构建,然后尝试其他构建。使用 nutch 的 Elasticsearch 版本控制似乎是最重要的部分,因为 ivy/ivy.xml 设置以及 indexer-elastic/plugin.xml 设置中关于 gora 的依赖性。

拜托,拜托,拜托,如果您对此有任何问题,请告诉我。我花了将近 2 整周的时间才弄清楚这个构建,我知道这会令人难以置信地沮丧。如果您 运行 遇到问题,请私信我或 post,我相信我可以帮助您解决这些问题。

Nutch 通过名为 2.x 的 gora 插件支持 elasticsearch 2.2.0 和 mongodb(对于 mongo 后端,您应该在 $NUTCH_HOME/ivy/ivy 中打开。 xml)

<dependency org="org.apache.gora" name="gora-mongodb" rev="0.6.1" conf="*->default" />

除此之外,$NUTCH_HOME/src/plugin/indexer-elastic2/howto_upgrade_es.txt

中还有如何升级 elasticsearch 的信息
  1. Upgrade elasticsearch dependency in $NUTCH_HOME/src/plugin/indexer-elastic2/ivy.xml

  2. Upgrade the Elasticsearch specific dependencies in src/plugin/indexer-elastic2/plugin.xml To get the list of dependencies and their versions execute:

$ ant -f ./build-ivy.xml
$ ls lib | sed 's/^/      <library name="/g' | sed 's/$/"\/>/g'