admin管理员组

文章数量:1531708

2024年7月10日发(作者:)

科技情报开发与经济 

文章编号:1005—6033(2013)21—0137—02 

SCI—TECH INFORMATION DEVELOPMENT&ECONOMY 2013年第23卷第21期 

收稿日期:2013—09—04 

搜索引擎在构建图书馆网站 

统一检索系统中的应用 

宿大东 

(南京图书馆,江苏南京,210018) 

摘要:采用开源软件Nutch和elasticsearch搭建了一个网站统一检索原型系统,用于 

解决图书馆门户网站建设过程中遇到的跨站点统一检索问题,并描述了具体的实施细 

节,在网络信息采集和检索应用方面具有一定的参考意义。 

关键词:统一检索;检索系gE;资源采集 

中图分类号:G254.924 文献标识码:A 

在图书馆门户网站建设过程中,通常需要实现网站内容的 

检索功能,主要是在网站系统中检索内容数据库,通过字段匹配 

来获得相关内容。这适用于单一的规模不是很大的网站。但在有 

些情况下,图书馆门户网站下面会挂接多个相对独立的站点,如 

果采用基于数据库开发跨多个站点的检索功能,实现起来比较 

始一轮新的抓取循环。 

当抓取循环彻底结束,Nutch调用elasticseach搜索模块为抓 

取中生成的Segments创建索引,丢弃索引中有重复Ud和内容 

重复的网页,并合并Segments中的索引,生成最终的用于检索的 

Indeces。这样用户就可以通过搜索界面提交搜索请求,通过搜索 

模块并行检索,获取查询结果。图1为检索系统工作流程图。 

复杂,检索效率也不会很高。而基于网络搜索引擎技术实现网站 

检索功能可能是一个更好的选择,因为搜索引擎天生具有跨多 

网站进行检索的功能。本文将采用开源软件搭建一个试验性的 

多网站统一检索系统,并在实际的场景中加以验证。 

1 Nutch和elasticsearch介绍 

Nutch是Apache基金会下面的企业级开源搜索引擎,提供了 

构建一个搜索引擎所需要的全部工具和功能,主要包括3个部 

分:抓取器(网络爬虫)、索引、搜索。使用Nutch不仅可以建立自 

己内部网的搜索引擎,同时也可以针对整个网络建立搜索引擎。 

1.7以后版本专注于内容抓取,索引和搜索功能由外部提供。 

elasticsearch是基于lucene的分布式实时搜索引擎。Nutch 

和elasticsearch配合使用,组成完整的搜索引擎应用,Nutch负责 

内容抓取,elasticsearch负责索引和查询。由于elastiesearch性能 

强大,配置简单,分布式扩展性好,所以很多知名的大型网站利 

用其实现检索功能。著名的Github使用elasticsearch集群搜索它 

的20TB的代码数据。 

图1检索系统工作流程图 

3构建图书馆统一检索系统 

利用Nutch和elasticsearch构建图书馆统一检索系统。Nutch 

爬行图书馆多个站点,抓取相应的网页数据,建立索引数据库, 

当需要浏览最终数据时,自动转发用户请求到相应的站点,这样 

就建立了跨多个站点的统一检索平台。接下来我们开始搭建实 

验环境,测试用Nutch和elastiesearch进行内容抓取和检索。 

3.1使用Nutch抓取数据 

2检索系统工作流程 

检索系统工作流程如下:首先,Nutch根据WebDB中的种子 

Url建立一个初始的待抓取的网页Url集合Fetchlist,接着抓取 

线程Fetchers并开始根据Fetchlist抓取网页,如果抓取线程有多 

(1)安装环境:CentOS6.3;jdk1.7.0_25;分布式数据库 

cassandra-1_2.8:apache-ant一1.9.2 

(2)到nutch.apache.org下载nutch2.2.1的源代码包,下载完 

成后解压。 

(3)配置Nutch使用cassandra作为数据存储,修改Nutch根 

目录下ivy/ivy.xml文件,取消注释:<dependency org=“org.apache. 

gora”name=“gora—cassandra”rev=“0-3”cord'=“ 一>default”,> 

个,会生成多个Fetchlist,每个Fetcher有一个对应的Fetehlist。然 

后Fetchers根据抓取的网页对WebDB进行更新,根据更新后的 

WebDB生成新的Fetchlist,里面是新发现或未抓取的Urls,并开 

修改Nutch根目录下conf/gora.properties文件,把默认存储 

】37 

宿大东搜索引擎在构建图书馆网站统一检索系统中的应用 本刊E—mail:bjb@sxinfo.net 信息工作研究 

配置改成如下: 

名称,主机之间可以利用p2p协议自动发现伙伴并组成集群。 

gora.cassandrastore.servers=loealhost:9160,并启动cassandra。 

(4)修改conf目录下的nutch—site.xml文件,在<configuration> 

标签下加入: 

<property> 

(2)测试使用elasticsearch建立索引。如果已经运行了 

elasticsearch,在Nutch根目录下运行下面的命令建立索引:bin/ 

nutch elasticindex elustername all,将clustemame替换为指定集群 

名称,本例设置为elastieseareh。 

<name>http.agent.name</name> 

通过阅读Nutch代码发现,Nutch以嵌入式方式来使用 

elasticsearch,不能在实际的生产环境下使用,需要修改 

ElasticWriter.java代码才能连接到外部的elasticsearch服务器上: 

public void open(TaskAttemptContext job)throws IOException{,/ 

<value>mySpider</value> 

</property> 

?<property> 

<name>http.accept.1anguage</name> 

<value>zh—an,en—us,en—gb,en;q=0.7,★;q O.3</value> 

</property> 

<property> 

<name>parser.character.encoding.defauh</name> 

<value>utf-8</value> 

/<property> 

<property> 

<name>storage.data.store.class</name> 

<value>org apache.gora.cassandra.store.CassandraStore</value> 

/<property> 

<property> 

<name>plugin.includes</name> 

<value>protocol-httplurlifher-regexIparse一(htmlltika)lindex一 

(basic lanchor)lurlnormalizer-(pass Iregex Ibasic)Iseoring—opic<, 

value> 

/<property> 

(5)使用ant编译源码。在Nutch根目录下输入ant,会生成 

runtime目录。 

(6)数据抓取。建立初始要抓取的url:cd mntime/l。cal& 

mkdir—P urls 

新建urls/url-lxt文件,添加要采集的网址列表: 

http://www.jslib.org.an 

http://www.jsgxge.org.an 

开始抓取数据:bi/nnutch crawl uds/ur1.txt—depth 10 topN 50. 

可以将Nutch设置成定时抓取。 

3.2使用elasticsearch为抓取内容建立索引并查询 

(1)安装配置elasticsearch。运行elastiesearch需要Jdk,前面 

已经安装好java运行环境。下载安装包并解压到安装目录: 

https://eodeload.github.com]medcl/elasticseareh-rtfzip/master,此安 

装包已经配置好分词插件、carrot2搜索结果聚合插件以及 

elasticsearch—servicewrapper系统服务支持包,运行bi/nservice/ 

elasticsearch?instlal安装为系统服务,bi/nservice elasticsearch 

start/stop启动和停止服务。 

如果分布式部署,在conifg目录下的elasticsearch.yml文件 

中可以设置集群名称。集群主机在同一网段,必须设置成一致的 

】38 

将前7行注销掉,改成 

Settings settings=Immutab1eSettings.settingsBuilder() 

put(“cluster.name”,“elasticsearch”) 

put(“client.transport.sniff'’.true) 

put(“node.client”,true) 

put(“client.transport.ping_timeout”,“10s”).build(); 

client=new TransportClient(settings).addTmnsponAddress 

(newInetSocketTransportAddress(“127.0.0.1”,9300));……} 

安装elasticsearch—head插件:bi/nplugin—install mobz/ 

elasticsearch—head 

在浏览器中输入http://lcoalhost:9200/__plugin/head/,可以看 

到抓取到的数据(见图2)。 

粤 蓬z董 》 受 :~ =一:=一~:一j=一一一 ∑  ’…… ~:~ : j =蕊 童 一:一::::~ 蔫雌 

曼 蠛 妻 : 卿-m * 黼{ ’ 

…… ’ 蛳 ~。。k 

4结语 

本文试图解决图书馆门户网站建设过程中遇到的跨多个站 

点统一检索的问题,并采用开源软件Nutch和elasticsearch搭建 

了一个统一检索原型系统。该系统配置简单、性能强大并且具有 

可扩展性,不仅能够有效解决跨站点的检索问题,在图书馆自建 

数据库的跨库检索等方面也有一定的应用前景。该系统在细节 

方面还存在一些不足,需要根据实际情况进行定制开发。 

参考文献 

[1] 王天怡.基于词典的中文分词算法研究及其在Nuteh系统 

中的应用[D].长春:吉林大学,2012. 

[2]叶海.分布式主题搜索引擎的研究与实现[D]广州:华南理 

工大学,2011. 

[3]徐健,张智雄.基于Nutch的Web网站定向采集系统[J]_ 

现代图书情报技术,2009(4):1-6. 

[4]韩云辉.基于Lucene的数字版权资源库的构建与应用研究 

[D].北京:北京工业大学,2013. (下转第157页) 

任雪磊高职院校图书馆建设与发展研究综述 本刊E-maihbjb@sxinfo.net 综述 

职业技术学院学报,2010(3):77—80. 

[15]鲁国晶.西部民族地区高职院校图书馆建设刍议[J].黄冈 

职业技术学院学报,2008(1):51—53. 

(实习编辑:曲磊) 

第一作者简介:任雪磊,女,1985年l2月生,2009年毕业于 

华东师范大学日本语言文学专业,助理馆员,宁波大红鹰学院图 

书馆,浙江省宁波市鄞州区学院路899号,315175. 

Review of the Research on the Construction and Development 

of Library of Higher Vocational College 

REN Xuelei 

ABSTRACT:This paper expounds the current situation of the construction and development of the library of higher 

vocational colleges,and from three aspects of the publishing years,literature sources and literature contents,studies and 

analyzes the pertinent literatures about the constuctrion and development of the library of higher vocational college,which 

is helpful to grasp the research status and development of library constuctrion and development trends of the library of 

higher vocational college. 

KEY WORDS:library;higher vocational college;constuctrion;development 

(上接第108页) 

Statistical Analysis on Sci-tech Papers of Shanxi Province in 201 1 

LI Qiang 

ABSTRACT:This paper makes a statistical analysis on sci-tech papers of Shanxi Province collected by SCI and EI in 201 1 

from aspects of the number of sci-tech papers,subject areas,distribution of regions and agencies,high output authors,interval 

distirbution ofinternational papers(SCI),and impact factor,etc.The data show that the scientiifc research ability and academic 

level of universities and research institutions in Shanxi Province have increased largely,but compared with other provinces in 

our country,Shanxi Province still needs to be further improved in the quantity and quality of sci-tech papers. 

EY KWORDS:sci—tech paper;statistical analysis;Shanxi Province 

(上接第138页) 

[5]Reference guide.elasticsearch[EB/OL].[2013—08—10].http:// 

vA ̄N'W.elasti csearch.org/uigde/. 

第一作者简介:宿大东,男,1974年9月生,1999年毕业于 

北京大学编辑学专业,馆员,南京图书馆信息资源开发部,江苏 

(责任编辑:李敏) 

省南京市中山东路189号,210002. 

The Application of Search Engine in Constructing the Uniied f

Retrieval System of Library Website 

SU Dadong 

ABSTRACT:This paper sets up a uniifed website retrieval prototype system by using the open source softwares Nutch and 

elastieseareh for solving the cross—site uniied retfievalr problem existing in the process of the constuctrion of library’s 

portal website,and describes the speciifc implementation details,which has a certain reference signiifcance in aspects of 

network information collection and retrieval applications. 

KEY WORDS:uniifed retieval;retrievalr system;resource collection 

1 S7 

本文标签: 检索图书馆抓取网站统一