-->
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: building simple queries
PostPosted: Tue Oct 12, 2010 1:53 pm 
Newbie

Joined: Sat Aug 16, 2008 1:54 am
Posts: 2
Hi,

I am new to hibernate search and apologize in advance for the basic nature of my question.

According to the documentation, one has to build a Lucene query and use it to perform a search, and the creation of the Lucene query is out of scope.

I have defined @Fields and boost factors using annotations in my entity classes, which hibernate search uses for indexing. Could the annotations not be used in building the query, in simple cases?

My simple case is: use all fields annotations, and OR them. It seems that what i need to do is create a Boolean query and add one query clause for each field I have defined, using the boost factors I already have defined in the entity classes.
* Is there a utility that does this for me automatically?
* Otherwise, does the hibernate search api provide a way to instantiate or initialize query clauses from org.hibernate.search.annotations.* annotations used in entity classes (or xml config)?

Thank you.


Top
 Profile  
 
 Post subject: Re: building simple queries
PostPosted: Wed Oct 13, 2010 6:28 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi jbells, welcome.
The way you make queries is not always the "inverse process" of how the index is built, you'll grasp that concept with a bit of practice, so creating a query from the annotated model would rarely cover a real world use case, it's way more likely that for a specific query you need to select a subset of fields, and apply some options to the way they are used.

See the first query example in the reference documentation, it uses a MultiFieldQueryParser which is handy to implement what you're asking.
So you need to define a set of fields to be considered, but no more work is needed. The boost factors defined as entities are applied at index time, so there's no need to specify them again at query time (that will get you a different result).
In more advanced chapters there are some hints about when you should consider index-time boosting or query time-boosting; it's very advanced (read: hard to maintain and understand, rarely used) to define boosting at both query time and index time, so especially during your first experiments avoid it unless you're an expert in scoring, relevancy and precision of information retrieval systems.

Let me know if this is more clear to you now, or we might consider improving that first chapter.

_________________
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.  [ 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.