|
锁定老贴子 主题:Hibernate Lucene 的集成
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2007-06-09
Hibernate Lucene IntegrationHibernate Lucene 的集成Lucene is a high-performance Java search engine library available from Lucene是一个高性能的java搜索引擎库,可以从 Apache软件基金组织获取。Hibernate Annotations包括一个注解包,它允许把任何域模型对象标记为可索引的,并且对任何经由Hibernate进行持续化的实例,Hibernate 都会为之维护一个对应的Lucene索引。 Using Lucene to index your entities使用Lucene为实体建立索引Annotating your domain model注解域模型First, we must declare a persistent class as 首先,必须将一个持久类声明为@Indexed: programlisting
@Entity
The index attribute tells Hibernate where the 属性index是告诉Hibernate, Lucene索引信息所在的位置(你文件系统的某个目录)。如果你想为所有的Lucene索引定义一个根目录,你可以在配置文件中用属性hibernate.lucene.index_dir进行配置。 Lucene indexes contain four kinds of fields: Lucene索引包括四种字段: keyword字段,text字段,unstored字段和unindexed字段。Hibernate注解提供了将实体属性标记为前三种被索引字段的注解。 programlisting
@Entity
These annotations define an index with three fields: 这些注解定义了一个带有三个字段的索引:Id, Abstract 和 Note: you must specify 注意:你必须在你的实体类的标志属性上指定@Keyword(id=true) 。 The analyzer class used to index the elements is configurable 用于对元素建立索引的分析器类是可以通过hibernate.lucene.analyzer属性进行配置的。如果没有定义,则把org.apache.lucene.analysis.standard.StandardAnalyzer作为缺省。 Enabling automatic indexing激活自动索引Finally, we enable the LuceneEventListener for 我们激活用于帧听三类Hibernate事件的LuceneEventListener,这些事件会在变更被提交至数据库后产生。 programlisting
...
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
浏览 1106 次



review 完毕:
1. Apache Software Foundation, Apache软件基金组织
index attribute tells Hibernate where the Lucene index is located
hibernate.lucene.analyzer property.
LuceneEventListener for
2. domain model object,领域模型对象
3. First, we must declare a persistent class as @Indexed
首先我们必须将持久类声明为@Indexed
4. The
属性index告知Hibernate,Lucene索引信息所在的位置
5. If you wish to define a base directory for all lucene indexes,
如果你想为......定义一个根目录(base directory)
6. one of the first three kinds of indexed fields.
......被索引字段......
7. These annotations define an index with three fields:
上述注解定义了一个带有三个字段的索引:
8. on the identifier property of
标识属性(identifier property)
9. The analyzer class used to index the elements is configurable through the
用于对元素建立索引的分析器类是可以通过......属性进行配置的
10. Enabling automatic indexing
激活自动索引
11. we enable the
the three Hibernate events that occur after changes are committed to the
database.
我们激活用于帧听三类Hibernate事件的LuceneEventListener,这些事件会在变更被提交至数据库后产生。