Chapter 3. hibernate search configuration

Apache Lucene has a 概念 of Directory to store the index files
这个目录实现可以自定义。但是Lucene绑定文件系统FSDirectoryProvider 内存模式memory(RAMDirectoryProvider)2种实现。Hibernate Search 提供DirectoryProvider 概念处理Lucene目录问题。内建Directory Providers

1 org.hibernate.search.store.FSDirectoryProvider
2 org.hibernate.search.store.FSMasterDirectoryProvider
3 org.hibernate.search.store.FSSlaveDirectoryProvider
4 org.hibernate.search.store.RAMDirectoryProvider

2,3实现应该是为[url=http://wutao8818.iteye.com/blog/146981]JMS模式的集群部署[/url]设置的。单机部署不需要。如果这些都不合适你。可以实现org.hibernate.store.DirectoryProvider interface

每个被索引的实体被分配一个lucene索引(一个索引能被多个实体共享。虽然大部分时候不这么用。)你能配置索引通过属性prefixed by hibernate.search.indexname。

默认属性继承给所有的索引可以被定义使用 the prefix hibernate.search.default.

定义索引目录provider。可以使用hibernate.search.indexname.directory_provider
-------------------------------------------------
hibernate.search.Rules.directory_provider org.hibernate.search.store.RAMDirectoryProvider

将Rules索引设置为内存模式。

hibernate.search.default.directory_provider org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=/usr/lucene/indexes

上面2行配置将在/usr/lucene/indexes/Status保存Stauts对象的索引信息
-------------------------------------------------

3.4索引切割

在一些极端情况,涉及到大尺寸的是索引文件。必须切割成多个索引文件。但不建议这样除非达到巨大的数量并且更新索引的速度很慢。主要的缺点是查询将变慢。因为不得不为单个搜索打开更多的文件。换句话说,除非迫不得已不要这样做!
尽管如此,hibernate search依然允许你索引到多个子索引中,通过使用IndexShardingStrategy.默认情况是不打开的。除非分割的数量被配置了。
[quote]hibernate.search.<indexName>.sharding_strategy.nbr_of_shards 5[/quote]

这部分内容还有很多,参考英文文档。因为我暂时不需要这个!

3.6打开hibernate search和自动索引功能

Hibernate Search is enabled out of the box when using Hibernate Annotations or Hibernate EntityManager.
如果需要关闭,设置hibernate.search.autoregister_listeners为false

Note that
[quote]there is no performance runtime when the listeners are enabled while no entity is indexable.[/quote]

要使用hibernate search功能。添加FullTextIndexEventListener。[quote]Once again, such a configuration is not useful with
Hibernate Annotations or Hibernate EntityManager.[/quote]
再说一次。这个配置对Annotations EntityManager无效??什么意思?没明白。

Be sure to add the appropriate jar files in your classpath

添加合适的包。。

hibernate-search.jar lucene-core.*.jar

如果使用Hibernate Core 3.2.6及以上版本,确保添加了额外的事件监听以应付集合事件。(collection events)
[quote]<event type="post-collection-recreate"/>
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>[/quote]

这些额外的事件监听器是在3.2.6被引入的。注意FullTextIndexCollectionEventListener的用法。你必须明确的引用这些事件监听除非你使用Hibernate Annotations3.3.1及以上。

3.6.2自动索引。

默认自动在通过hibernate添加删除更新时索引。一些时间期望关闭这些功能。如索引为只读或者索引更新批量see Chapter 6, Manual indexing

[quote]hibernate.search.indexing_strategy manual[/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值