org.infinispan.query
Interface CacheQuery

All Superinterfaces:
Iterable<Object>
All Known Implementing Classes:
CacheQueryImpl, ClusteredCacheQueryImpl

public interface CacheQuery
extends Iterable<Object>

A cache-query is what will be returned when the getQuery() method is run on SearchManagerImpl. This object can have methods such as list, setFirstResult,setMaxResults, setFetchSize, getResultSize and setSort.

Author:
Manik Surtani, Navin Surtani, Sanne Grinovero (C) 2011 Red Hat Inc.
See Also:
SearchManagerImpl#getQuery(org.apache.lucene.search.Query)

Method Summary
 CacheQuery disableFullTextFilter(String name)
          Disable a given filter by its name.
 org.hibernate.search.FullTextFilter enableFullTextFilter(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
 CacheQuery filter(org.apache.lucene.search.Filter f)
          Allows lucene to filter the results.
 CacheQuery firstResult(int index)
          Sets a result with a given index to the first result.
 org.hibernate.search.query.engine.spi.FacetManager getFacetManager()
           
 int getResultSize()
          Gets the integer number of results.
 QueryIterator iterator()
          Returns the results of a search as a QueryIterator.
 QueryIterator iterator(int fetchSize)
          Returns the results of a search as a QueryIterator with a given integer parameter - the fetchSize.
 QueryIterator lazyIterator()
          Calls the lazyIterator(int fetchSize) method but passes in a default 1 as a parameter.
 QueryIterator lazyIterator(int fetchSize)
          Lazily loads the results from the Query as a QueryIterator with a given integer parameter - the fetchSize.
 List<Object> list()
          Returns the results of a search as a list.
 CacheQuery maxResults(int numResults)
          Sets the maximum number of results to the number passed in as a parameter.
 CacheQuery projection(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"

A projectable field must be stored in the Lucene index and use a org.hibernate.search.bridge.TwoWayFieldBridge Unless notified in their JavaDoc, all built-in bridges are two-way.

 CacheQuery sort(org.apache.lucene.search.Sort s)
          Allows lucene to sort the results.
 

Method Detail

list

List<Object> list()
Returns the results of a search as a list.

Returns:
list of objects that were found from the search.

iterator

QueryIterator iterator(int fetchSize)
Returns the results of a search as a QueryIterator with a given integer parameter - the fetchSize.

Parameters:
fetchSize - integer to be given to the implementation constructor.
Returns:
a QueryResultIterator which can be used to iterate through the results that were found.

iterator

QueryIterator iterator()
Returns the results of a search as a QueryIterator. This calls iterator(int fetchSize) but uses a default fetchSize of 1.

Specified by:
iterator in interface Iterable<Object>
Returns:
a QueryResultIterator which can be used to iterate through the results that were found.

lazyIterator

QueryIterator lazyIterator(int fetchSize)
Lazily loads the results from the Query as a QueryIterator with a given integer parameter - the fetchSize.

Parameters:
fetchSize - integer to be passed into the lazy implementation of QueryIterator
Returns:
a QueryResultIterator which can be used to lazily iterate through results.

lazyIterator

QueryIterator lazyIterator()
Calls the lazyIterator(int fetchSize) method but passes in a default 1 as a parameter.

Returns:
a QueryResultIterator which can be used to lazily iterate through results.

firstResult

CacheQuery firstResult(int index)
Sets a result with a given index to the first result.

Parameters:
index - of result to be set to the first.
Throws:
IllegalArgumentException - if the index given is less than zero.

maxResults

CacheQuery maxResults(int numResults)
Sets the maximum number of results to the number passed in as a parameter.

Parameters:
numResults - that are to be set to the maxResults.

getFacetManager

org.hibernate.search.query.engine.spi.FacetManager getFacetManager()
Returns:
return the manager for all faceting related operations

getResultSize

int getResultSize()
Gets the integer number of results.

Returns:
integer number of results.

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 key
Returns:
Lucene Explanation

sort

CacheQuery sort(org.apache.lucene.search.Sort s)
Allows lucene to sort the results. Integers are sorted in descending order.

Parameters:
s - - lucene sort object

projection

CacheQuery projection(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"

A projectable field must be stored in the Lucene index and use a org.hibernate.search.bridge.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[]

Parameters:
fields - the projected field names
Returns:
this to allow for method chaining

enableFullTextFilter

org.hibernate.search.FullTextFilter enableFullTextFilter(String name)
Enable a given filter by its name.

Parameters:
name - of filter.
Returns:
a FullTextFilter object.

disableFullTextFilter

CacheQuery disableFullTextFilter(String name)
Disable a given filter by its name.

Parameters:
name - of filter.

filter

CacheQuery filter(org.apache.lucene.search.Filter f)
Allows lucene to filter the results.

Parameters:
f - - lucene filter

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.