---
title: "精致的桌面全文搜索引擎regain安装配置简介"
author: "monner"
date: "2008-10-15T21:17:00Z"
tags: []
categories: ["企业架构"]
slug: "regain"
draft: false
lastmod: "2008-10-15T21:17:00Z"
id: 253348
url: "https://monner.iteye.com/blog/253348"
---

**一、Regain简要介绍**(摘录网上)
regain是一款与Web搜索引擎类似的桌面搜索引擎系统，其不同之处在于regain不是对Internet内容的搜索，而是针对自己的文档或文件的搜索，使用regain可以轻松地在几秒内完成大量数据（许多个G）的搜索。**Regain采用了Lucene的搜索语法，因此支持多种查询方式，支持多索引的搜索及基于文件类型的高级搜索，并且能实现URL重写及文件到HTTP的桥接，并且对中文也提供了较好的支持。**  

Regain提供了两种版本：桌面搜索及服务器搜索。桌面搜索提供了对普通桌面计算机的文档与局域网环境下的网页的快速搜索。服务器版本主要安装在Web服务器上，为网站及局域网环境下的文件服务器进行搜索。  

Regain使用Java编写，因此可以实现跨平台安装，能安装于Windows、Linux、Mac OS及Solaris上。服务器版本需要 JSPs环境及标签库（tag library），因此需要安装一个Tomcat容器。而桌面版自带了一个小型的Web服务器，安装非常简单。

**二、安装配置简介**
大致知道了regain是什么以后，如果regain的功能正好是您需要的，那我们就来一起进行安装配置吧。
1.下载regain最新版本。主页http://regain.sourceforge.net/
如果只是安装使用的话，可以直接这里下载编译好的版本：http://regain.sourceforge.net/download.php提供多种平台的最新稳定版本。如果是研究学习，或者想自己做优化修改，则建议下载带源码的版本：http://sourceforge.net/project/showfiles.php?group_id=111168

2.下载后解压到特定目录，本文范例以 e:\Devp\Java\JavaApp\regain 目录为解压目录

3.如果仅仅是下载编译好的版本安装试用的话，几乎都不需要什么设置，直接解压后，打开命令行窗口进入安装目录，直接运行 
**
java -jar regain.jar **命令行

运行后会在右下角systray系统托盘处出现regain的形状为“r”的小图标，右击会弹出search\status\Perferences菜单。直接选择Search就会打开查询页面。其实如果第一次运行，系统会自动弹出欢迎页面。Perferences设置页面可以增加用户要索引的文件数据目录和web端口。

4.更多设置在conf目录中，主要设置文件包括如下4个文件，设置都非常简单直观
现在把比较重要的设置稍做解释。

（1）SearchConfiguration.xml  主要包括查询模块的设置。
 ...
    <!-- The search index 'main' -->
    <index name="main" default="true" isparent="true">
      <!-- The directory where the index is located -->
    **  <dir>D:\SearchEngine\Index\regainindex</dir>索引放置的目录**
    </index>

（2）DesktopConfiguration.xml 主要包括本地桌面查询设置，可通过perferences页面设置。


<configuration>

  <!-- The interval to update the search index in minutes -->
  <interval>1440</interval>
  
  <!-- Allow/Disallow external access to the running desktop instance -->
  <allow_external_access>true</allow_external_access>

**<port>60009</port> 端口**

</configuration>


（3）CrawlerConfiguration.xml 主要包括数据抓取和索引生成模块的设置


<startlist>
  <start index="false" parse="true">**file://D:/SearchEngine/Data**</start>
  **关键参数！！！ 设置用户需要进行索引的文档资料目录！可通过perferences页面设置。**
</startlist>

<searchIndex>
  <!-- The directory where the index should be located -->
**  <dir>D:\SearchEngine\Index\regainindex</dir>索引放置的目录，同文件1的设置**

  <!--
   | Specifies the analyzer type to use.
   |
   | You may specify the class name of the analyzer or you use one of the
   | following aliases: 
   |  * english: For the english language
   |    (alias for org.apache.lucene.analysis.standard.StandardAnalyzer)
   |  * german: For the german language
   |    (alias for org.apache.lucene.analysis.de.GermanAnalyzer)
   |  * **paoding: 个人增加的paoding分词模块**
   |  * **chinese: 个人增加的中文模块**
   +-->
**  <analyzerType>paoding</analyzerType> 
  默认是german，建议修改为english,
当然最好就是替换成中文模块，我会在后面把整个替换步骤单独讲。**

  <!--
   | Contains all words that should not be indexed.
   | Separate the words by a blank.
   +-->
**  <stopwordList/>
  词语分割符号，实际相当于词法分析时做分割的词语列表。
（默认的设置不是这样的，我修改是因为我已修改为中文分词模块，这个参数没什么必要！
   其实如果用户选择english，此参数也用途不大，因为默认是german分割符号）**

  <!--
   | Contains all words that should not be changed by an analyser when indexed.
   | Separate the words by a blank.
   +-->
**  <exclusionList/>生成索引时需要排除的词语列表(中文模块则此参数也没有什么必要)**

（4）log4j.properties         
    日志输出配置
    
5.基本上上述设置后regain应该可以运行。
regain是个不可多得的本地文件全文索引和快速全文搜索工具！虽然它也支持抓取互联网或者局域网页面数据进行索引。但是作为本地桌面全文搜索工具来讲，它比较专业精致，而且完美支持中文文件和中文目录。

谁乐意和我一起研究研究这个系统呢~~~