-->
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.  [ 3 posts ] 
Author Message
 Post subject: [Hibernate Search] Searching only one type of entity
PostPosted: Fri Jul 06, 2007 6:03 pm 
Newbie

Joined: Fri Jul 06, 2007 5:45 pm
Posts: 5
Hi!

my problem ist probably trivial, but I couldn't find an answer anywhere in the Hibernate Search documentation: how do I force HS or Lucene to only return objects of a particular kind?

Imagine an application where I have two kinds of Entites, say User and Product, both with a field "name". Both are indexed, so when I do a query like "name:foo", I will not only find Mr. John Foo, but also the FooProduct. My result set is just a mixed bag, so if I solve this via "instanceof", my pagination and result count will be messed up.

A simple way to work around this is renaming the field "name", e.g. to "userName" and "productName". But this is not only ugly in itself but also a clever user could manage to circumvent the "default" field and query the others.

I know that restricting the kind of entities returned by a query kind of defeats the purpose of full-text indexing, but it sure makes sense in my case (and no, I don't actually index users).

Cheers, Friedrich


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 4:19 am 
Newbie

Joined: Wed Jul 04, 2007 12:03 pm
Posts: 14
check the documentation : chapter 4 querying - you see you can pass the class

if your problem is that you want to access lucene natively, HS adds an extra property with the class of the entity : use Luke (lucene tool) to investigate your lucene indexes


Top
 Profile  
 
 Post subject: ....
PostPosted: Mon Jul 09, 2007 4:38 am 
Newbie

Joined: Fri Jul 06, 2007 5:45 pm
Posts: 5
oops. excuse me for asking such an obvious question - the documentation is really quite clear on that once you look at the right place :-)

thanks for the nice reply.


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