我正在尝试使用hibernate-search-4.3.0.Final.jar创建一个休眠全文搜索 此应用程序中没有错误,但我的 Lucene 查询取消查询 DSL 不返回任何结果。我的意思是它不会返回表中的任何行。谁能帮帮我吗。
这是我的功能:
OgmConfiguration cfgogm=new OgmConfiguration();
cfgogm.configure("hibernate.cfg.xml");
serviceregistry=new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
sessionfactory=cfgogm.buildSessionFactory(serviceregistry);
Session session= sessionfactory.openSession();
FullTextSession fulltextsession= Search.getFullTextSession(session);
QueryBuilder querybuilder=fulltextsession.getSearchFactory().buildQueryBuilder().forEntity(User.class).get();
org.apache.lucene.search.Query lucenequery=querybuilder.keyword().onField("IdU").matching("96645").createQuery();
org.hibernate.search.FullTextQuery fulltextquery=fulltextsession.createFullTextQuery(lucenequery, User.class);
List result=fulltextquery.list();
System.out.println(result.toString());
这是我的 POJO 课程:
@Entity
@Table(name="Users")
@Indexed
public class User {
@Id
@GeneratedValue(generator="mongodb_uuidgg")
@Field(index = Index.YES,analyze = Analyze.NO,store = Store.NO)
private String _id;
@Column(name="City")
@Field(index = Index.YES,analyze = Analyze.NO,store = Store.NO)
private String city;
@Column(name="UserID")
@Field(index = Index.YES,analyze = Analyze.NO,store = Store.NO)
private int IdU;
...