休止状態検索用のサンプル プロジェクトを作成しましたが、例外なく正常に動作しますが、その文字列を持つオブジェクトがある文字列を検索すると、空が返されます。どうすればいいのかわからない!!!誰か助けてくれませんか...プロジェクトはMavenベースで、休止状態と休止状態の検索の両方に休止状態の注釈を使用しています。ここに私の hibernate.cfg.xml ファイルがあります:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/eprnews
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<!--
<property name="hibernate.hbm2ddl.auto">create-drop</property>
Hibernate Search -->
<!-- org.hibernate.search.store.FSDirectoryProvider -->
<!-- org.hibernate.search.store.RAMDirectoryProvider for test -->
<!--
<property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
-->
<property name="hibernate.search.default.directory_provider">filesystem</property>
<property name="hibernate.search.default.indexBase">./indexes</property>
<!--
-->
<property name="hibernate.search.worker.execution">async</property>
<property name="hibernate.search.default.optimizer.transaction_limit.max">100</property>
<!-- Mapped classes -->
<mapping class="net.leemoo.test.entity.NewsEntity"/>
</session-factory>
</hibernate-configuration>
ここに私のエンティティがあります:
@Entity
@Table(name="news")
@Indexed
@AnalyzerDef(
name = "PersianAnal",
charFilters = @CharFilterDef(factory = PersianCharFilterFactory.class),
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters={
@TokenFilterDef(factory = ArabicNormalizationFilterFactory.class),
@TokenFilterDef(factory = PersianNormalizationFilterFactory.class)
}
)
public class NewsEntity {
@Id
@GeneratedValue
private Long id;
@Field
@Analyzer(definition="PersianAnal")
private String title;
@Field
@Analyzer(definition="PersianAnal")
private String newsAbstract;
@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
@Analyzer(definition="PersianAnal")
private String content;
@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
@DateBridge(resolution=Resolution.DAY)
private Date creationDate;
@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
@DateBridge(resolution=Resolution.DAY)
private Date modifiedDate;
private Integer viewsCounter;
@Field
@Analyzer(definition="PersianAnal")
private String keywords;
private Boolean jqueryNews;
private Boolean photoNews;
and setters and getters...
これは私が検索に使用するコードです:
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
FullTextSession fullTextSession = Search.getFullTextSession(session);
try {
// fullTextSession.createIndexer().startAndWait();
QueryBuilder gb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(NewsEntity.class).get();
Query query = gb.keyword().
onFields("title", "newsAbstract", "content").
matching("test").createQuery();
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, NewsEntity.class);
List<NewsEntity> result = (List<NewsEntity>)hibQuery.list();
System.out.println(result.size());
} catch (Exception e) {
// e.printStackTrace();
}
session.getTransaction().commit();
session.close();
私は何をすべきか?私を助けてください....