【问题标题】:Indexer IOException job fail while Indexing nutch crawled data in “Bluemix” solrIndexer IOException 作业在“Bluemix”solr 中索引 nutch 爬网数据时失败
【发布时间】:2016-10-18 14:01:47
【问题描述】:

我正在尝试通过 Bluemix solr 索引 nutch 爬网数据。我在命令提示符中使用了以下命令:

bin/nutch 索引 -D solr.server.url="https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/CLUSTER-ID/solr/admin/collections -D solr .auth=true -D solr.auth.username="USERNAME" -D solr.auth.password="PASS" 爬取/crawldb -linkdb 爬取/linkdb 爬取/segments/2016*

但它未能完成索引。结果如下:

Indexer: starting at 2016-06-16 16:31:50
Indexer: deleting gone documents: false
Indexer: URL filtering: false
Indexer: URL normalizing: false
Active IndexWriters :
SolrIndexWriter
        solr.server.type : Type of SolrServer to communicate with (default 'http' however options include 'cloud', 'lb' and 'concurrent')
        solr.server.url : URL of the Solr instance (mandatory)
        solr.zookeeper.url : URL of the Zookeeper URL (mandatory if 'cloud' value for solr.server.type)
        solr.loadbalance.urls : Comma-separated string of Solr server strings to be used (madatory if 'lb' value for solr.server.type)
        solr.mapping.file : name of the mapping file for fields (default solrindex-mapping.xml)
        solr.commit.size : buffer size when sending to Solr (default 1000)
        solr.auth : use authentication (default false)
        solr.auth.username : username for authentication
        solr.auth.password : password for authentication
Indexing 153 documents
Indexing 153 documents
Indexer: java.io.IOException: Job failed!
        at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:836)
        at org.apache.nutch.indexer.IndexingJob.index(IndexingJob.java:145)
        at org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:222)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.nutch.indexer.IndexingJob.main(IndexingJob.java:231)

我猜它与solr.server.url地址有关,可能是它的结尾。我用不同的方式改变了它 例如

https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/CLUSTER-ID/solr/example_collection/update”。

(因为它被 Bluemix Solr 用于索引 JSON/CSV/... 文件)。 但现在没有机会了。

有人知道我该如何解决吗?如果问题如我所料,任何人都知道 solr.server.url 究竟应该是什么? 顺便说一句,“example_collection”是我的集合名称,我正在使用 nutch1.11。

【问题讨论】:

    标签: indexing solr ibm-cloud nutch retrieve-and-rank


    【解决方案1】:

    据我所知,通过 nutch 本身提供的 index 命令(bin/nutch index...)在 Bluemix R&R 中对 nutch 爬网数据进行索引是不可能的。 我意识到,要在 Bluemix Retrieve and Rank 服务中索引 nutch 爬网数据,应该:

    1. 用 nutch 抓取种子,例如

      $:bin/crawl -w 5 urls crawl 25

    您可以通过以下方式查看抓取状态:

    bin/nutch readdb crawl/crawldb/ -stats

    1. 将抓取的数据转储为文件:

      $:bin/nutch dump -flatdir -outputDir dumpData/ -segment crawl/segments/

    2. 发布那些可能的,例如 xml 文件到 solr Collection on Retrieve and Rank:

      Post_url = '"https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/%s/solr/%s/update"' %(solr_cluster_id, solr_collection_name)
      cmd ='''curl -X POST -H %s -u %s %s --data-binary @%s''' %(Cont_type_xml, solr_credentials, Post_url, myfilename)          
      subprocess.call(cmd,shell=True)
      
    3. 使用 Bluemix Doc-Conv 服务将其余部分转换为 json:

      doc_conv_url = '"https://gateway.watsonplatform.net/document-conversion/api/v1/convert_document?version=2015-12-15"'
      cmd ='''curl -X POST -u %s -F config="{\\"conversion_target\\":\\"answer_units\\"}" -F file=@%s %s''' %(doc_conv_credentials, myfilename, doc_conv_url)
      process = subprocess.Popen(cmd, shell= True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      

      然后将这些 Json 结果保存到一个 json 文件中。

    4. 将此 json 文件发布到集合中:

      Post_converted_url = '"https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/%s/solr/%s/update/json/docs?commit=true&split=/answer_units/id&f=id:/answer_units/id&f=title:/answer_units/title&f=body:/answer_units/content/text"' %(solr_cluster_id, solr_collection_name)
      cmd ='''curl -X POST -H %s -u %s %s --data-binary @%s''' %(Cont_type_json, solr_credentials, Post_converted_url, Path_jsonFile)
      subprocess.call(cmd,shell=True)
      
    5. 发送查询:

      pysolr_client = retrieve_and_rank.get_pysolr_client(solr_cluster_id, solr_collection_name)
      results = pysolr_client.search(Query_term)
      print(results.docs)
      

      代码在 python 中。

    对于初学者:您可以直接在 CMD 中使用 curl 命令。我希望它可以帮助其他人。

    【讨论】:

      【解决方案2】:

      像这样:

      nutch index -Dsolr.server.url=http://username:password@localhost:8983/solr/nutch crawl/crawldb/ -linkdb crawl/linkdb/ crawl/segments/20170816191100/ -filter -normalize -deleteGone 
      

      它有效。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-03-04
        • 1970-01-01
        • 2013-09-17
        • 1970-01-01
        • 2013-05-16
        • 1970-01-01
        • 2021-03-02
        • 1970-01-01
        相关资源
        最近更新 更多