如何使用 Hibernate Search 执行搜索,该搜索不会从数据库中检索实际实体,而只会返回这些实体的文档缓存记录?我确保将我需要的字段存储在索引中。在此过程中数据库将处于活动状态且可用,我只是想减少不必要的负载。
@Column
@Field (index = Index.YES, store = Store.YES)
private String title;
@Id
@Column
@DocumentId
@Field (store = Store.YES)
private String guid;
Session sess = sessionFactory.openSession();
FullTextSession fts = org.hibernate.search.Search.getFullTextSession(sess);
//returns matching Articles from database, how would I retrieve only the index records?
Query query = fts.createFullTextQuery(luceneQuery, Article.class);
版本:
Hibernate Search 4.1.1.Final
Hibernate Core 4.1.6.Final
Lucene 3.5