com.mysema.query.lucene
Class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>

java.lang.Object
  extended by com.mysema.query.lucene.AbstractLuceneQuery<T,Q>
Type Parameters:
T - projection type
Q - concrete subtype of query
All Implemented Interfaces:
FilteredClause<Q>, SimpleProjectable<T>, SimpleQuery<Q>
Direct Known Subclasses:
LuceneQuery, TypedQuery

public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
extends Object
implements SimpleQuery<Q>, SimpleProjectable<T>

AbstractLuceneQuery is an abstract super class for Lucene query implementations

Author:
tiwe

Constructor Summary
AbstractLuceneQuery(LuceneSerializer serializer, org.apache.lucene.search.Searcher searcher, com.google.common.base.Function<org.apache.lucene.document.Document,T> transformer)
           
AbstractLuceneQuery(org.apache.lucene.search.Searcher searcher, com.google.common.base.Function<org.apache.lucene.document.Document,T> transformer)
           
 
Method Summary
 long count()
          Get the count of matched elements
 long countDistinct()
          Get the count of distinct matched elements
 Q distinct()
          Set the Query to return distinct results
 Q distinct(Path<?> property)
          Add a DuplicateFilter for the field of the given property path
 boolean exists()
           
 Q filter(org.apache.lucene.search.Filter filter)
          Apply the given Lucene filter to the search results
 com.mysema.commons.lang.CloseableIterator<T> iterate()
          Get the projection as a typed closeable Iterator
 com.mysema.commons.lang.CloseableIterator<T> iterateDistinct()
          Get the projection as a typed closeable Iterator with distinct elements
 Q limit(long limit)
          Defines the limit / max results for the query results
 List<T> list()
          Get the projection as a typed List
 List<T> listDistinct()
          Get the projection as a typed List with distinct elements
 SearchResults<T> listDistinctResults()
          Get the projection in SearchResults form with distinct element
 SearchResults<T> listResults()
          Get the projection in SearchResults form
 Q load(org.apache.lucene.document.FieldSelector fieldSelector)
          Set the given FieldSelector to the query
 Q load(Path<?>... paths)
          Load only the fields of the given paths
 boolean notExists()
           
 Q offset(long offset)
          Defines the offset for the query results
 Q orderBy(OrderSpecifier<?>... o)
          Defines the order expressions
 Q restrict(QueryModifiers modifiers)
          Defines both limit and offset of the query results
<P> Q
set(ParamExpression<P> param, P value)
          Set the given parameter to the given value
 T singleResult()
          Get the projection as a single result or null if no result is found
 Q sort(org.apache.lucene.search.Sort sort)
           
 String toString()
           
 T uniqueResult()
          Get the projection as a unique result or null if no result is found
 Q where(Predicate... e)
          Adds the given filter conditions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLuceneQuery

public AbstractLuceneQuery(LuceneSerializer serializer,
                           org.apache.lucene.search.Searcher searcher,
                           com.google.common.base.Function<org.apache.lucene.document.Document,T> transformer)

AbstractLuceneQuery

public AbstractLuceneQuery(org.apache.lucene.search.Searcher searcher,
                           com.google.common.base.Function<org.apache.lucene.document.Document,T> transformer)
Method Detail

exists

public boolean exists()
Specified by:
exists in interface SimpleProjectable<T>
Returns:
true, if rows matching the given criteria exist, otherwise false

notExists

public boolean notExists()
Specified by:
notExists in interface SimpleProjectable<T>
Returns:
true, if no rows matching the given criteria exist, otherwise false

count

public long count()
Description copied from interface: SimpleProjectable
Get the count of matched elements

Specified by:
count in interface SimpleProjectable<T>
Returns:

countDistinct

public long countDistinct()
Description copied from interface: SimpleProjectable
Get the count of distinct matched elements

Specified by:
countDistinct in interface SimpleProjectable<T>
Returns:

distinct

public Q distinct()
Description copied from interface: SimpleQuery
Set the Query to return distinct results

Specified by:
distinct in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

distinct

public Q distinct(Path<?> property)
Add a DuplicateFilter for the field of the given property path

Parameters:
property -
Returns:

filter

public Q filter(org.apache.lucene.search.Filter filter)
Apply the given Lucene filter to the search results

Parameters:
filter -
Returns:

limit

public Q limit(long limit)
Description copied from interface: SimpleQuery
Defines the limit / max results for the query results

Specified by:
limit in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

iterate

public com.mysema.commons.lang.CloseableIterator<T> iterate()
Description copied from interface: SimpleProjectable
Get the projection as a typed closeable Iterator

Specified by:
iterate in interface SimpleProjectable<T>
Returns:

iterateDistinct

public com.mysema.commons.lang.CloseableIterator<T> iterateDistinct()
Description copied from interface: SimpleProjectable
Get the projection as a typed closeable Iterator with distinct elements

Specified by:
iterateDistinct in interface SimpleProjectable<T>
Returns:

list

public List<T> list()
Description copied from interface: SimpleProjectable
Get the projection as a typed List

Specified by:
list in interface SimpleProjectable<T>
Returns:

load

public Q load(org.apache.lucene.document.FieldSelector fieldSelector)
Set the given FieldSelector to the query

Parameters:
fieldSelector -
Returns:

load

public Q load(Path<?>... paths)
Load only the fields of the given paths

Parameters:
paths -
Returns:

listDistinct

public List<T> listDistinct()
Description copied from interface: SimpleProjectable
Get the projection as a typed List with distinct elements

Specified by:
listDistinct in interface SimpleProjectable<T>
Returns:

listDistinctResults

public SearchResults<T> listDistinctResults()
Description copied from interface: SimpleProjectable
Get the projection in SearchResults form with distinct element

Specified by:
listDistinctResults in interface SimpleProjectable<T>
Returns:

listResults

public SearchResults<T> listResults()
Description copied from interface: SimpleProjectable
Get the projection in SearchResults form

Specified by:
listResults in interface SimpleProjectable<T>
Returns:

offset

public Q offset(long offset)
Description copied from interface: SimpleQuery
Defines the offset for the query results

Specified by:
offset in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

orderBy

public Q orderBy(OrderSpecifier<?>... o)
Description copied from interface: SimpleQuery
Defines the order expressions

Specified by:
orderBy in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

restrict

public Q restrict(QueryModifiers modifiers)
Description copied from interface: SimpleQuery
Defines both limit and offset of the query results

Specified by:
restrict in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

set

public <P> Q set(ParamExpression<P> param,
                 P value)
Description copied from interface: SimpleQuery
Set the given parameter to the given value

Specified by:
set in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
Returns:

sort

public Q sort(org.apache.lucene.search.Sort sort)

singleResult

public T singleResult()
Description copied from interface: SimpleProjectable
Get the projection as a single result or null if no result is found

for multiple results only the first one is returned

Specified by:
singleResult in interface SimpleProjectable<T>
Returns:

uniqueResult

public T uniqueResult()
Description copied from interface: SimpleProjectable
Get the projection as a unique result or null if no result is found

Specified by:
uniqueResult in interface SimpleProjectable<T>
Returns:

where

public Q where(Predicate... e)
Description copied from interface: FilteredClause
Adds the given filter conditions

Specified by:
where in interface FilteredClause<Q extends AbstractLuceneQuery<T,Q>>
Parameters:
e - filter conditions to be added
Returns:

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2012 Mysema Ltd. All Rights Reserved.