Hi Hardy,
Hope this will help you to understand my problem :)
Code:
FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);
List<InstantMessage> instantMessages = em.createQuery(
"select o from InstantMessage as o").getResultList();
for (InstantMessage instantMessage : instantMessages) {
fullTextEntityManager.index(instantMessage);
}
FullTextQuery fullTextQuery= getData();
javax.persistence.Query hibQuery= fullTextQuery;
List<InstantMessage> result = hibQuery.getResultList();
Code:
public FullTextQuery getData() {
FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);
String temp = "message";
QueryParser parser = new MultiFieldQueryParser(
new String[] { "message"}, new StandardAnalyzer());
Query query = null;
org.apache.lucene.search.Query luceneQuery= null;
try {
luceneQuery = parser
.parse(getSearchString());
} catch (ParseException parEx) {
parEx.printStackTrace();
}
return fullTextEntityManager.createFullTextQuery(luceneQuery, InstantMessage.class);
}
Code:
@Entity
@Indexed
@Analyzer
@Table(name = "INSTANTMESSAGE")
public class InstantMessage implements Serializable {
@DocumentId
@Id
@GeneratedValue
@Column(name = "INSTANTMESSAGEID")
long id;
@Column(name = "MESSAGE", unique = false, nullable = false, length = 50)
@Field(index=Index.TOKENIZED, store=Store.NO)
String message;
getter and setter.......
Any Idea Now :)