-->
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.  [ 2 posts ] 
Author Message
 Post subject: Sample code to add restrictions while doing search
PostPosted: Mon Jun 07, 2010 9:33 am 
Newbie

Joined: Mon Jun 07, 2010 9:18 am
Posts: 1
Hi Emmanuel,
I am Rajesh (NIT Warangal CSE(2006) .
I am new to beginner in Hibernate Search.
I know general hibernate also.
I want to write a code which is given below. I need to converted below code in hibernate search.

Code:
Criteria criteria = getSession().createCriteria(ShopModel.class);
criteria.add(Restrictions.or(Restrictions.eq(Constant.TYPE, Constant.SHOP_TYPE_RENT),
                    Restrictions.eq(Constant.TYPE, Constant.SHOP_TYPE_SELL)));

similarly for   Restrictions.in(.....);


Please help me regarding this by giving any simple code.
Thanks you very much.
Rajesh


Top
 Profile  
 
 Post subject: Re: Sample code to add restrictions while doing search
PostPosted: Wed Jun 09, 2010 6:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Rajesh,

You should start with the tutorial of the online documentation of Search to get an understanding on how Search works. Most importantly you have to decide which of your entities you want to be indexed and which properties of these entities (@Entity and @Field annotations). Anything which you now use in a Restrictions has to be indexed in one way or another. In the end you need to write a Lucene query which matches what you do via Criteria now. Best you have a look at the Lucene documentation and see how queries look like.

Note, that Search is really about freetext search and really shines when searching over bodies of texts. If your search is just including some constants you might be better of with Criteria queries.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.