hey thanx Hardy to reply to my post,
I had made the changes as you suggest me in recent post but still it returns the null result.
See my code below....
======================searcher.java file code===============================
Code:
String[] productFields = { "name_astp", "description_astp" }; // targeted fields
// Map<String, Float> boostPerField = new HashMap<String, Float>(2); // boost
// factors
// boostPerField.put("name_astp", (float) 4);
// boostPerField.put("description_astp", (float) 1);
// QueryParser parser = new MultiFieldQueryParser(productFields,new
// StandardAnalyzer(),boostPerField);
//QueryParser parser = new QueryParser("name_astp", new StandardAnalyzer());
QueryParser parser = new MultiFieldQueryParser(productFields,
new StandardAnalyzer());
org.apache.lucene.search.Query luceneQuery;
try {
luceneQuery = parser.parse(seachKeyStr);
} catch (ParseException e) {
throw new RuntimeException("Unable to parse query: " + seachKeyStr,
e);
}
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
FullTextSession ftSession = org.hibernate.search.Search.createFullTextSession(session);
// ftSession=org.hibernate.search.Search.getFullTextSession(session);
Query query = ftSession.createFullTextQuery(luceneQuery); // return, Item.class
@SuppressWarnings("unchecked")
List<Item> results = null;
try {
results = query.list();
} catch (Exception ex) {
ex.printStackTrace();
}
//======================Item.hbm.xml============================================
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Example 2.7 -->
<hibernate-mapping package="com.manning.hsia.dvdstore.model">
<class name="AmAssetType" table="am_asset_type_astp"> <!-- mapping externalized in hbm.xml files -->
<id name="id">
<generator class="native"/>
</id>
<property name="name_astp"/>
<property name="description_ast"/>
</class>
</hibernate-mapping>
//============================= hibernate.cfg.xml =====================================
Code:
<?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">
<!-- Example 2.3 -->
<hibernate-configuration>
<session-factory>
<!-- database configuration -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://192.168.1.12:3306/dvdstore</property>
<property name="connection.username">root</property>
<property name="connection.password">admin</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<property name="show_sql">true</property>
<!-- generate schema -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Hibernate Search configuration -->
<property name="hibernate.search.default.indexBase">./build/indexes</property>
<property name="hibernate.search.default.directory_provider">org.hibernate.search.store.RAMDirectoryProvider</property>
<!-- classes mapping -->
<mapping class="com.manning.hsia.dvdstore.model.Item"/>
</session-factory>
</hibernate-configuration>
hope you will get clear idea about what exactly I am trying to do........
Thank you in advance.