-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: no result in hibernate search
PostPosted: Mon Aug 15, 2011 4:49 am 
Newbie

Joined: Mon Aug 15, 2011 4:37 am
Posts: 2
I have a problem with hibernate search where the results of the query in the form of an empty list. Here is snippet of coding..
Domain
public class Book {

@Id
@GeneratedValue
@DocumentId
private Integer id;

@Field(index = Index.UN_TOKENIZED, store = Store.NO)
private String title;

@Field(index = Index.UN_TOKENIZED, store = Store.NO)
private String isbn;

@Field(index = Index.UN_TOKENIZED, store = Store.NO)
private String publisher;

@Field(index = Index.UN_TOKENIZED, store = Store.NO)
@Column(name = "description", length = 1500)
private String desc;


DAO
@SuppressWarnings({ "rawtypes", "unchecked" })
public Set doSearching(String searchKey) throws ParseException {
System.out.println("searchKey : " + searchKey);
Session session = getSessionFactory().openSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
final QueryBuilder b = fullTextSession.getSearchFactory()
.buildQueryBuilder().forEntity(Book.class).get();

org.apache.lucene.search.Query luceneQuery = b.keyword()
.onFields("title", "publisher", "desc", "isbn")
.matching(searchKey).createQuery();
org.hibernate.Query fullTextQuery = fullTextSession
.createFullTextQuery(luceneQuery);
List result = fullTextQuery.list();
int bd = result.size();
System.out.println("List size of query : " + bd);

Date date = this.getDate(searchKey);
List resultByDate = null;

if (date != null) {
luceneQuery = b.keyword().onField("dateOfPublication")
.matching(this.getDate(searchKey)).createQuery();
fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery);
resultByDate = fullTextQuery.list();
}
// Because od some reason, we are getting duplicate result.
// This fix is just to get unique result.
Set uniqueResult = new HashSet();
if (!(result == null || result.size() == 0)) {
uniqueResult.addAll(result);
}
if (!(resultByDate == null || resultByDate.size() == 0)) {
uniqueResult.addAll(resultByDate);
}
int a = uniqueResult.size();
System.out.println("size of list "+a);
return uniqueResult;
}


result


searchKey : %dfdfdf%
searchKey : %dfdfdf%
List size of query : 0
size of list 0

please any body help me...thanks


Top
 Profile  
 
 Post subject: Re: no result in hibernate search
PostPosted: Mon Aug 15, 2011 5:58 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
I guess you forgot the @Indexed annotation? See here.


Top
 Profile  
 
 Post subject: Re: no result in hibernate search
PostPosted: Mon Aug 15, 2011 6:54 am 
Newbie

Joined: Mon Aug 15, 2011 4:37 am
Posts: 2
Thanks before..
I have added @indexed like this,
@Entity
@Indexed
public class Book

but i have a similar problem as no result, please help me....


Top
 Profile  
 
 Post subject: Re: no result in hibernate search
PostPosted: Mon Aug 15, 2011 7:08 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
Okay. Can you give an example of a Book entity with its data fields and a query term that should match?
What I would do is analyze the Lucene index with Luke to check if the terms you search for are really there.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.