-->
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: Hibernate Search, Newbie question: showing the lucene query?
PostPosted: Tue Apr 05, 2011 8:34 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Hi,

I'm new to Hibernate search, and would appreciate help :)

1) "Hibernate search in action" mentions (quote): "In a query involving multiple words, the closer they are in a document, the higher the rank".
So I understand if I search for "big ben", then an item containing
- "BIG BEN is in London"
gets higher ranking than
- "It's a BIG day for my dear friend BEN"
However, I don't think such a feature is build into Lucene core (at least so they claim in the Lucene forum)...?
Is my information wrong about Lucene?
Or does Hibernate Search achieve this feature through additional coding?

2) More generally, can you configure Hibernate Search to print out any Lucene Query it runs?
(Similar to Hibernate Core feature of printing out any SQL queries it runs)

Thanks :)


Top
 Profile  
 
 Post subject: Re: Hibernate Search, Newbie question: showing the lucene query?
PostPosted: Wed Apr 06, 2011 8:36 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
solmyr72 wrote:
1) "Hibernate search in action" mentions (quote): "In a query involving multiple words, the closer they are in a document, the higher the rank".
So I understand if I search for "big ben", then an item containing
- "BIG BEN is in London"
gets higher ranking than
- "It's a BIG day for my dear friend BEN"
However, I don't think such a feature is build into Lucene core (at least so they claim in the Lucene forum)...?
Is my information wrong about Lucene?
Or does Hibernate Search achieve this feature through additional coding?

Nope, Hibernate Search does not apply any additional pixie dust. The book text is maybe a little confusing. Maybe it refers to PhraseQueries? If you use a big slop factor you kind of get what you are talking about.

solmyr72 wrote:
2) More generally, can you configure Hibernate Search to print out any Lucene Query it runs?
(Similar to Hibernate Core feature of printing out any SQL queries it runs)

In your code you are always generating Lucene queries. Just call toString on your Lucene query. There is at the moment no configuration/logging setting to turn this on/off automatically. I like the idea though

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Search, Newbie question: showing the lucene query?
PostPosted: Wed Apr 06, 2011 8:42 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, welcome.

Quote:
1) "Hibernate search in action" mentions (quote): "In a query involving multiple words, the closer they are in a document, the higher the rank".
So I understand if I search for "big ben", then an item containing
- "BIG BEN is in London"
gets higher ranking than
- "It's a BIG day for my dear friend BEN"
However, I don't think such a feature is build into Lucene core (at least so they claim in the Lucene forum)...?
Is my information wrong about Lucene?
Or does Hibernate Search achieve this feature through additional coding?

No additional coding, it's in Lucene; see description of org.apache.lucene.search.PhraseQuery, especially on the setSlop(int) method.

When annotating a property in Hibernate Search, experiment with different values of Field(termVector), by the default positional information is not stored.

Quote:
2) More generally, can you configure Hibernate Search to print out any Lucene Query it runs?
(Similar to Hibernate Core feature of printing out any SQL queries it runs)

You make the Query yourself, or get a reference to the query via the queryBuilder service, you can then invoke "toString()" on it to get a good description.

You can also invoke "explain" on a org.hibernate.search.query after you've run it to have it explain how a specific score was calculated.

Code:
org.hibernate.search.FullTextQuery.explain(int)

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


Top
 Profile  
 
 Post subject: Re: Hibernate Search, Newbie question: showing the lucene query?
PostPosted: Wed Apr 06, 2011 11:22 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Thanks for both replies.
It really helped :)


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.