-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Wed Feb 02, 2011 3:07 pm 
Beginner
Beginner

Joined: Fri Jun 29, 2007 2:19 pm
Posts: 26
Location: Fremont, CA
We recently upgraded to 3.3 and noticed that our field queries http://lucene.apache.org/java/3_0_2/queryparsersyntax.html#Fields stopped working. This used to work in previous version. We use keyword search on multiple fields, do we need to change anything there?
Code:
luceneQuery = testQB.bool().should(testQB.keyword().onField("tc.name").boostedTo((float) 2).matching(words).createQuery())
                     .should(testQB.keyword().onField("tc.description").boostedTo((float) 1).matching(words).createQuery())
                     .
                     .
                     .
                     .should(testQB.keyword().onField("tc.comments").boostedTo((float) 2).matching(words).createQuery())
                     .createQuery();

Search actually works fine but doesnt limit the result to that particular field (which it used to).
e.g. searching for xyz and tc.name:xyz will yield same result (in other word, it will match xyz in tc.comments and tc.description ignoring the specified field).

Some obvious we are missing?

_________________
-shailesh


Top
 Profile  
 
 Post subject: Re: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Wed Feb 02, 2011 7:49 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
well since Lucene's "should" means roughly the boolean opertor "OR" (the only difference is the way the scores are calculated), it looks like you have put the value xyz in OR on all fields, so what you say is expected: if any of those fields contains "xyz" it will match.

What is your goal?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Wed Feb 02, 2011 8:24 pm 
Beginner
Beginner

Joined: Fri Jun 29, 2007 2:19 pm
Posts: 26
Location: Fremont, CA
for the field query, we would like to limit it to only that field. We used to use MultiFieldQueryParser (before upgrading to 3.3), should we go back to using that?

_________________
-shailesh


Top
 Profile  
 
 Post subject: Re: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Wed Feb 02, 2011 9:10 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
if you only want to search one specific field, you definitely don't need MultiFieldQueryParser.
Just avoid mentioning the other fields in the QueryBuilder.
I'm quite confused, you mentioned before that
Quote:
We use keyword search on multiple fields
: so multiple fields. please write an example of what you want to obtain.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Wed Feb 02, 2011 9:34 pm 
Beginner
Beginner

Joined: Fri Jun 29, 2007 2:19 pm
Posts: 26
Location: Fremont, CA
sorry about confusion. What we want is free form search, user can type any text and search across multiple fields brings the result based on ranking. But in certain scenarios, user may want to run specific search on a particular field, we want to accomodate the same.
Example:
Search xyz
Expected result, search for all the fields having word xyz, and present the ranked results

Search tc.name:xyz
Expected result, search for only name field having word xyz, and present the results

We have no logic at back end trying to detect the difference and we leave it to parser to apply field filter.

Really boils down to, should we continue using MultiFieldQueryParser or switch to DSL.

_________________
-shailesh


Top
 Profile  
 
 Post subject: Re: Hibernate Search 3.3: Field Query doesnt work
PostPosted: Thu Feb 03, 2011 7:51 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Ok, now I understood.
MultiFieldQueryParser is more appropriate to parse user input. Actually the DSL isn't able to provide such a query right now: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-634

_________________
Sanne
http://in.relation.to/


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