簡體   English   中英

休眠搜索索引無法正常工作

[英]java - hibernate search indexing not working

我正在嘗試將休眠搜索集成到現有應用程序中。 根據休眠搜索的教程,我在applicationContext.xml的休眠屬性中添加了以下屬性

<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>  
<prop key="hibernate.search.default.indexBase">./lucene/indexes</prop> 

另外,我在要啟用搜索的實體類上添加了注釋。 在類上使用@Indexed,在字段上使用@Field。

以下是我使用的版本(我不使用Maven):

  • 休眠搜索-3.2.0.Final
  • 休眠公共注釋4.0.1最終版
  • 休眠核心-4.1.11最終版
  • 休眠實體管理員-3.4.0.GA
  • 春天-3.2.2 REALEASE
  • lucene-core-3.2.0

我正在使用此示例代碼在MySQL數據庫中執行搜索:

public void search() {

FullTextSession searchSession = Search.getFullTextSession(sessionFactory.getCurrentSession());

QueryParser parser = new QueryParser(Version.LUCENE_32, "contenu", new StandardAnalyzer(Version.LUCENE_32));

org.apache.lucene.search.Query query = parser.parse("décarbonateront");

org.hibernate.Query hibQuery = searchSession.createFullTextQuery(query, Book.class);

List result = hibQuery.list();

System.out.println("lucene results: " + result.size());

}

但我收到此錯誤: The type org.hibernate.classic.Session cannot be resolved. It is indirectly referenced from required .class files The type org.hibernate.classic.Session cannot be resolved. It is indirectly referenced from required .class files

在: searchSession.createFullTextQuery(query, Book.class);

可能是什么問題?

您需要對齊Hibernate和Hibernate Search版本。 Hibernate Search 3.2需要Hibernate3.5.x。 檢查Maven pom中的版本-https: //repository.jboss.org/nexus/content/repositories/public/org/hibernate/hibernate-search-parent/3.2.0.Final/hibernate-search-parent- 3.2.0.Final.pom

您也可以從Sourceforge下載Hibernate Search發行版。 該發行版還包含所有正確的依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM