Code:
session = HibernateUtil.getSessionFactory().openSession();
FullTextSession fullTextSession = Search.createFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
//
List<Video> lst = session.createQuery("from Video as video").list();
for (Video vid : lst) {
fullTextSession.index(vid);
}
MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{"Year"},
new StandardAnalyzer());
org.apache.lucene.search.Query query;
org.hibernate.Query hibQuery = null;
try {
query = (org.apache.lucene.search.Query)parser.parse( "2003" );
hibQuery = fullTextSession.createFullTextQuery( query, Video.class );
} catch (ParseException e) {
e.printStackTrace();
}
List result = hibQuery.list();
tx.commit();
if (session != null) {
session.close();
}
result = 0;
What is wrong?
Data Base has 11 records, 3 from them is 2003 year