没有合适的资源?快使用搜索试试~ 我知道了~
hibernate_search.pdf
需积分: 0 4 下载量 125 浏览量
2009-03-19
06:25:13
上传
评论
收藏 387KB PDF 举报
温馨提示
试读
65页
hibernate_search.pdf
资源详情
资源评论
资源推荐
Hibernate Search
Apache Lucene Integration
Version: 3.1.0.GA
Table of Contents
Preface ............................................................................................................................................iv
1. Getting started ............................................................................................................................1
1.1. System Requirements .........................................................................................................1
1.2. Using Maven .....................................................................................................................1
1.3. Configuration .....................................................................................................................2
1.4. Indexing ............................................................................................................................5
1.5. Searching ...........................................................................................................................6
1.6. Analyzer ............................................................................................................................7
1.7. What's next ........................................................................................................................9
2. Architecture .............................................................................................................................. 10
2.1. Overview ......................................................................................................................... 10
2.2. Back end ......................................................................................................................... 10
2.2.1. Back end types ...................................................................................................... 11
2.2.1.1. Lucene ....................................................................................................... 11
2.2.1.2. JMS ........................................................................................................... 11
2.2.2. Work execution ..................................................................................................... 12
2.2.2.1. Synchronous ............................................................................................... 12
2.2.2.2. Asynchronous ............................................................................................ 13
2.3. Reader strategy ................................................................................................................ 13
2.3.1. Shared .................................................................................................................. 13
2.3.2. Not-shared ............................................................................................................ 13
2.3.3. Custom ................................................................................................................. 13
3. Configuration ............................................................................................................................ 14
3.1. Directory configuration .................................................................................................... 14
3.2. Sharding indexes .............................................................................................................. 16
3.3. Sharing indexes (two entities into the same directory) ......................................................... 17
3.4. Worker configuration ....................................................................................................... 17
3.5. JMS Master/Slave configuration ........................................................................................ 18
3.5.1. Slave nodes ........................................................................................................... 19
3.5.2. Master node .......................................................................................................... 20
3.6. Reader strategy configuration ............................................................................................ 21
3.7. Enabling Hibernate Search and automatic indexing ............................................................ 21
3.7.1. Enabling Hibernate Search ..................................................................................... 21
3.7.2. Automatic indexing ............................................................................................... 22
3.8. Tuning Lucene indexing performance ................................................................................ 22
4. Mapping entities to the index structure ..................................................................................... 26
4.1. Mapping an entity ............................................................................................................ 26
4.1.1. Basic mapping ....................................................................................................... 26
4.1.2. Mapping properties multiple times .......................................................................... 28
4.1.3. Embedded and associated objects ........................................................................... 28
4.1.4. Boost factor .......................................................................................................... 31
4.1.5. Analyzer ............................................................................................................... 32
4.1.5.1. Analyzer definitions .................................................................................... 33
4.1.5.2. Available analyzers ..................................................................................... 34
4.1.5.3. Analyzer discriminator (experimental) ......................................................... 35
4.1.5.4. Retrieving an analyzer ................................................................................ 36
4.2. Property/Field Bridge ....................................................................................................... 37
4.2.1. Built-in bridges ..................................................................................................... 37
Hibernate 3.1.0.GA ii
4.2.2. Custom Bridge ...................................................................................................... 38
4.2.2.1. StringBridge ............................................................................................... 38
4.2.2.2. FieldBridge ................................................................................................ 40
4.2.2.3. ClassBridge ................................................................................................ 41
4.3. Providing your own id ...................................................................................................... 42
4.3.1. The ProvidedId annotation ..................................................................................... 42
5. Querying ................................................................................................................................... 44
5.1. Building queries ............................................................................................................... 45
5.1.1. Building a Lucene query ........................................................................................ 45
5.1.2. Building a Hibernate Search query .......................................................................... 45
5.1.2.1. Generality .................................................................................................. 45
5.1.2.2. Pagination .................................................................................................. 45
5.1.2.3. Sorting ....................................................................................................... 46
5.1.2.4. Fetching strategy ........................................................................................ 46
5.1.2.5. Projection ................................................................................................... 47
5.2. Retrieving the results ........................................................................................................ 48
5.2.1. Performance considerations .................................................................................... 48
5.2.2. Result size ............................................................................................................ 48
5.2.3. ResultTransformer ................................................................................................. 49
5.2.4. Understanding results ............................................................................................ 49
5.3. Filters .............................................................................................................................. 50
5.4. Optimizing the query process ............................................................................................ 53
5.5. Native Lucene Queries ..................................................................................................... 54
6. Manual indexing ....................................................................................................................... 55
6.1. Indexing .......................................................................................................................... 55
6.2. Purging ............................................................................................................................ 56
7. Index Optimization ................................................................................................................... 57
7.1. Automatic optimization .................................................................................................... 57
7.2. Manual optimization ......................................................................................................... 57
7.3. Adjusting optimization ..................................................................................................... 58
8. Advanced features ..................................................................................................................... 59
8.1. SearchFactory .................................................................................................................. 59
8.2. Accessing a Lucene Directory ........................................................................................... 59
8.3. Using an IndexReader ...................................................................................................... 59
8.4. Customizing Lucene's scoring formula .............................................................................. 60
Hibernate Search
Hibernate 3.1.0.GA iii
Preface
Full text search engines like Apache Lucene are very powerful technologies to add efficient free text search
capabilities to applications. However, Lucene suffers several mismatches when dealing with object domain
model. Amongst other things indexes have to be kept up to date and mismatches between index structure and
domain model as well as query mismatches have to be avoided.
Hibernate Search addresses these shortcomings - it indexes your domain model with the help of a few annota-
tions, takes care of database/index synchronization and brings back regular managed objects from free text
queries. To achieve this Hibernate Search is combining the power of Hibernate [http://www.hibernate.org] and
Apache Lucene [http://lucene.apache.org].
Hibernate 3.1.0.GA iv
Chapter 1. Getting started
Welcome to Hibernate Search! The following chapter will guide you through the initial steps required to integ-
rate Hibernate Search into an existing Hibernate enabled application. In case you are a Hibernate new timer we
recommend you start here [http://hibernate.org/152.html].
1.1. System Requirements
Table 1.1. System requirements
Java Runtime A JDK or JRE version 5 or greater. You can down-
load a Java Runtime for Windows/Linux/Solaris here
[http://java.sun.com/javase/downloads/].
Hibernate Search hibernate-search.jar and all runtime dependencies
from the lib directory of the Hibernate Search distri-
bution. Please refer to README.txt in the lib direct-
ory to understand which dependencies are required.
Hibernate Core This instructions have been tested against Hibernate
3.3.x. You will need hibernate-core.jar and its
transitive dependencies from the lib directory of the
distribution. Refer to README.txt in the lib directory
of the distribution to determine the minimum runtime
requirements.
Hibernate Annotations Even though Hibernate Search can be used without
Hibernate Annotations the following instructions will
use them for basic entity configuration (@Entity,
@Id, @OneToMany,...). This part of the configura-
tion could also be expressed in xml or code.
However, Hibernate Search itself has its own set of
annotations (@Indexed, @DocumentId, @Field,...)
for which there exists so far no alternative configura-
tion. The tutorial is tested against version 3.4.x of Hi-
bernate Annotations.
You can download all dependencies from the Hibernate download site [http://www.hibernate.org/6.html]. You
can also verify the dependency versions against the Hibernate Compatibility Matrix
[http://www.hibernate.org/6.html#A3].
1.2. Using Maven
Instead of managing all dependencies manually, maven users have the possibility to use the JBoss maven re-
pository [http://repository.jboss.com/maven2]. Just add the JBoss repository url to the repositories section of
your pom.xml or settings.xml:
Example 1.1. Adding the JBoss maven repository to settings.xml
Hibernate 3.1.0.GA 1
剩余64页未读,继续阅读
train8k
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- oracle 触发器语法及 for each row 详细说明
- 微信小程序-豆瓣图书源码
- Fragment - Unknow animation name objectAnimator 问题解决及源码分析
- 词向量-中文文本相似度计算-采用text2vec词向量工具进行计算对比.zip
- 521293804316625base(1).apk
- ARP IP地址分类及特殊IP
- 【MySQL补丁】vcredist-x64xz MySQL必备插件
- 基于SG3525芯片PWM控制推挽隔离DCDC电源模块AD09设计硬件(原理图+PCB)工程文件.zip
- Word_20240428_092324.docx
- cloudcc_v1.1.10-release_sign.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0