ZoieSystem

ZoieSystem是可以使用spring进行配置的,一个典型的配置如下:

<!--An instance of a DataProvider:

FileDataProvider recurses through a given directory and provides the DataConsumer

indexing requests built from the gathered files.

In the example, this provider needs to be started manually, and it is done via jmx.

一个DataProvider的实例:

FileDataProvider递归的访问一个指定的路径,将得到的文件构造成索引请求提供给DataConsumer。

在本例中,此生产者需要通过jmx进行手动启动。

-->

<bean id="dataprovider" class="proj.zoie.impl.indexing.FileDataProvider">

<constructor-arg value="file:${source.directory}"/>

<property name="dataConsumer" ref="indexingSystem" />

</bean>

<!--

an instance of an IndexableInterpreter:

FileIndexableInterpreter converts a text file into a lucene document, for example

purposes only

一个IndexableInterpreter的实例:

在本例中,FileIndexableInterpreter将一个文本文件转换成为一个Lucene的Document对象。

从上面的介绍中我们知道,DataProvider作为一个生产者生产了DataEvent对象供消费者DataConsumer进行消费,然而由于Zoie最终是基于Lucene的,Lucene是不能够索引DataEvent对象的,这就需要有人负责将DataEvent转换成为Lucene的Document对象,根据应用的需要控制添加那些Field,添加什么样的Field等,此工作由翻译器Interpreter完成。

-->

<bean id="fileInterpreter" class="proj.zoie.impl.indexing.FileIndexableInterpreter" />

<!-- A decorator for an IndexReader instance:

The default decorator is just a pass through, the input IndexReader is returned.

一个IndexReader的装饰者:

默认的装饰者什么都不做,将原IndexReader返回。

注意这里使用的是一个重要的设计模式,装饰者模式。被包装的IndexReader是直接打开Lucene索引的IndexReader,IndexReaderFactory在得到这些IndexReader后,都会经过此类封装一下,再返回给用户。基本的Lucene的IndexReader打开,会加载和初始化一些基本的东西,然而有时候,用户需要在IndexReader打开的时候,同时加载一些自己的东西,此类给了用户这样一个机会,用户只要实现自己的装饰者就可以了。在和Zoie同一个项目Bobo(实现Facet搜索,使用过Solr的同学可能会比较熟悉)中,实现了BoboIndexReaderDecorator,其作用就是在IndexReader打开的时候,将Facet信息加载到内存中形成某种数据结构,从而在收集Facet的时候快速的使用。

-->

<bean id="idxDecorator" class="proj.zoie.impl.indexing.DefaultIndexReaderDecorator" />

<!-- A zoie system declaration, passed as a DataConsumer to the DataProvider declared above

一个ZoieSystem的声明,在上面的DataProvider的声明中,其是作为一个DataConsumer传入的。

-->

<bean id="indexingSystem" class="proj.zoie.impl.indexing.ZoieSystem" init-method="start" destroy-method="shutdown">

<!-- disk index directory 索引文件夹-->

<constructor-arg index="0" value="file:${index.directory}"/>

<!-- sets the interpreter 设置翻译器-->

<constructor-arg index="1" ref="fileInterpreter" />

<!-- sets the decorator 设置装饰器-->

<constructor-arg index="2">

<ref bean="idxDecorator"/>

</constructor-arg>

<!-- set the Analyzer, if null is passed, Lucene's StandardAnalyzer is used

设置分词器,如果为null,则使用默认的Lucene的StandardAnalyzer

-->

<constructor-arg index="3">

<null/>

</constructor-arg>

<!-- sets the Similarity, if null is passed, Lucene's DefaultSimilarity is used

设置相似性评分器,如果为null,则使用Lucene默认的DefaultSimilarity

-->

<constructor-arg index="4">

<null/>

</constructor-arg>

<!-- the following parameters indicate how often to triggered batched indexing,

whichever the first of the following two event happens will triggered indexing

下面的两个参数表示触发批量索引的频率,任意一个满足条件则触发索引。

-->

<!-- Batch size: how many items to put on the queue before indexing is triggered

批量大小:<!-- 一个是积累多少文档进行flush -->

-->

<constructor-arg index="5" value="1000" />

<!-- Batch delay, how long to wait before indxing is triggered

批量延时:<!-- 一个是延迟多长时间flush. ms 在两个中间有一个达到的时候,内存flush到硬盘上 -->

-->

<constructor-arg index="6" value="300000" />

<!-- flag turning on/off real time indexing

是否开启实时索引的标志位

-->

<constructor-arg index="7" value="true" />

</bean>



<!-- a search service 一个搜索服务 -->

<bean id="mySearchService" class="com.mycompany.search.SearchService">

<!-- IndexReader factory that produces index readers to build Searchers from

ZoieSystem作为IndexReaderFactory向搜索服务提供IndexReader列表,使其可以构造Searcher。

-->

<constructor-arg ref="indexingSystem" />

</bean>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值