---
title: "nutch输出文件的读取"
author: "wq163"
date: "2007-01-03T18:40:00Z"
tags: []
slug: "nutch"
draft: false
lastmod: "2007-01-03T18:40:00Z"
id: 91329
url: "https://jen2.iteye.com/blog/91329"
---

Nutch的输出文件（不包括临时文件）主要可分为crawldb、index、indexs、linkdb和segments。

**Crawldb&lt;o:p&gt;&lt;/o:p&gt;**

       Crawldb是所有需要抓取的超连接信息

**Segments&lt;o:p&gt;&lt;/o:p&gt;**

Segments是每轮抓取的时候根据crawldb生成的。存放的信息包括6种content、crawl\_fetch、crawl\_generate、crawl\_parse、parse\_data、parse\_text。其中content是抓取下来的网页内容；crawl\_generate最初生成；crawl\_fetch、content在抓取时生成；crawl\_parse、parse\_data、parse\_text在解析抓取的数据文件时生成。其中crawl\_generate、crawl\_fetch和crawl\_parse是crawldb的部分url数据，它们格式一样，不同的是抓取时间、状态、签名等有所变化。格式如下：

////////////////////crawl\_generate、crawl\_fetch、crawl\_parse、crawldb的格式//////////////

http://www.163.com/     Version: 4

Status: 5 (fetch\_success)

Fetch time: Thu Oct 26 19:20:33 CST 2006

Modified time: Thu Jan 01 08:00:00 CST 1970

Retries since fetch: 0

Retry interval: 30.0 days

Score: 1.0

Signature: &lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3029" unitname="C"&gt;3029c&lt;/st1:chmetcnv&gt;621e&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="26" unitname="C"&gt;26c&lt;/st1:chmetcnv&gt;&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="43797241" unitname="a"&gt;43797241a&lt;/st1:chmetcnv&gt;8d34980b2dc

Metadata: null

parse\_data的格式如下:

……

outlink: toUrl: http://cha.so.163.com/so.php?key=001001006&q=%CA%D6%BB%FA  anchor: 手机

Content Metadata: nutch.crawl.score=1.0 nutch.content.digest=&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3029" unitname="C"&gt;3029c&lt;/st1:chmetcnv&gt;621e&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="26" unitname="C"&gt;26c&lt;/st1:chmetcnv&gt;&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="43797241" unitname="a"&gt;43797241a&lt;/st1:chmetcnv&gt;8d34980b2dc Content-Type=text/html;

charset=GB2312 date=Thu, 26 Oct 2006 11:20:33 GMT Cache-Control=max-age=146

Content-Encoding=gzip Content-Length=19628 Connection=close Expires=Thu, 26

Oct 2006 11:23:00 GMT nutch.segment.name=20061026192026 Accept-Ranges=bytes

Server=Apache/&lt;st1:chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"&gt;2.0.55&lt;/st1:chsdate&gt; (Unix) X-Cache=HIT from www.163.com Vary=Accept-Encoding

Parse Metadata: OriginalCharEncoding=GB2312 CharEncodingForConversion=GB2312

parse\_text是网页的文本信息。

**Index&lt;o:p&gt;&lt;/o:p&gt;**

据初步分析index由indexs合并而来的，存放的是索引信息。在非分布式搜索时优先根据查找index文件夹，如果不存在则查找indexs。

**Linkdb&lt;o:p&gt;&lt;/o:p&gt;**

Linkdb中存放的是所有超连接及其每个连接的连入地址和锚文本。读取出来的格式如下：

http://tech.163.com/06/1025/18/2UA64IC300091537.html  Inlinks:

 fromUrl: http://tech.163.com/discover/ anchor:

 fromUrl: http://tech.163.com/discover/ anchor: 蟒蛇鳄鱼颠峰对决

……