org.hibernate.search.jpa
Interface FullTextQuery

All Superinterfaces:
ProjectionConstants, javax.persistence.Query
All Known Implementing Classes:
FullTextQueryImpl

public interface FullTextQuery
extends javax.persistence.Query, ProjectionConstants

The base interface for lucene powered searches. This extends the JPA Query interface

Author:
Hardy Ferentschik, Emmanuel Bernard

Field Summary
 
Fields inherited from interface org.hibernate.search.ProjectionConstants
BOOST, DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, THIS
 
Method Summary
 void disableFullTextFilter(java.lang.String name)
          Disable a given filter by its name
 FullTextFilter enableFullTextFilter(java.lang.String name)
          Enable a given filter by its name.
 org.apache.lucene.search.Explanation explain(int documentId)
          Return the Lucene Explanation object describing the score computation for the matching object/document in the current query
 int getResultSize()
          Returns the number of hits for this search Caution: The number of results might be slightly different from getResultList().size() because getResultList() may be not in sync with the database at the time of query.
 FullTextQuery setCriteriaQuery(org.hibernate.Criteria criteria)
          Defines the Database Query used to load the Lucene results.
 FullTextQuery setFilter(org.apache.lucene.search.Filter filter)
          Allows to use lucene filters.
 FullTextQuery setProjection(java.lang.String... fields)
          Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row" (similar to an HQL or a Criteria API projection).
 FullTextQuery setResultTransformer(org.hibernate.transform.ResultTransformer transformer)
          defines a result transformer used during projection
 FullTextQuery setSort(org.apache.lucene.search.Sort sort)
          Allows to let lucene sort the results.
 
Methods inherited from interface javax.persistence.Query
executeUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getResultList, getSingleResult, isBound, setFirstResult, setFlushMode, setHint, setLockMode, setMaxResults, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, unwrap
 

Method Detail

setSort

FullTextQuery setSort(org.apache.lucene.search.Sort sort)
Allows to let lucene sort the results. This is useful when you have additional sort requirements on top of the default lucene ranking. Without lucene sorting you would have to retrieve the full result set and order the hibernate objects.

Parameters:
sort - The lucene sort object.
Returns:
this for method chaining

setFilter

FullTextQuery setFilter(org.apache.lucene.search.Filter filter)
Allows to use lucene filters. Semi-deprecated? a preferred way is to use the @FullTextFilterDef approach

Parameters:
filter - The lucene filter.
Returns:
this for method chaining

getResultSize

int getResultSize()
Returns the number of hits for this search Caution: The number of results might be slightly different from getResultList().size() because getResultList() may be not in sync with the database at the time of query.


setCriteriaQuery

FullTextQuery setCriteriaQuery(org.hibernate.Criteria criteria)
Defines the Database Query used to load the Lucene results. Useful to load a given object graph by refining the fetch modes No projection (criteria.setProjection() ) allowed, the root entity must be the only returned type No where restriction can be defined either.


setProjection

FullTextQuery setProjection(java.lang.String... fields)
Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row" (similar to an HQL or a Criteria API projection). A projectable field must be stored in the Lucene index and use a TwoWayFieldBridge Unless notified in their JavaDoc, all built-in bridges are two-way. All @DocumentId fields are projectable by design. If the projected field is not a projectable field, null is returned in the object[]


enableFullTextFilter

FullTextFilter enableFullTextFilter(java.lang.String name)
Enable a given filter by its name. Returns a FullTextFilter object that allows filter parameter injection


disableFullTextFilter

void disableFullTextFilter(java.lang.String name)
Disable a given filter by its name


setResultTransformer

FullTextQuery setResultTransformer(org.hibernate.transform.ResultTransformer transformer)
defines a result transformer used during projection


explain

org.apache.lucene.search.Explanation explain(int documentId)
Return the Lucene Explanation object describing the score computation for the matching object/document in the current query

Parameters:
documentId - Lucene Document id to be explain. This is NOT the object id
Returns:
Lucene Explanation


Copyright © 2006-2010 Hibernate. All Rights Reserved.