Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Search(Lucene) additional Parameters

Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've been using hibernate search quite successfully, but now I want to add a condition to the search query but since I'm not writing the query myself, I'm not sure how to do this..

My current code for the query is :

FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
// create native Lucene query
String[] fields = new String[]{"title", "description"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer()); query = parser.parse(search);
// wrap Lucene query in a org.hibernate.Query
FullTextQuery hibQuery = fullTextEntityManager.createFullTextQuery(query, Film.class);
// execute search
//List result = hibQuery.list();
results = hibQuery.getResultList();

And what I want to do is add a 'WHERE' type clause to the above in addition to the fulltextquery..

Anyone any ideas how to do this? I've noticed the hibQuery allows 'setParameter' but without being able to set a query string I'm not sure how it would work..

Thanks in advance.

Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!