org.compass.core.impl
Class DefaultCompassQuery

java.lang.Object
  extended by org.compass.core.impl.DefaultCompassQuery
All Implemented Interfaces:
Cloneable, CompassQuery
Direct Known Subclasses:
DefaultCompassQuery.DefaultCompassSpanQuey

public class DefaultCompassQuery
extends Object
implements CompassQuery, Cloneable

Author:
kimchy

Nested Class Summary
static class DefaultCompassQuery.DefaultCompassSpanQuey
           
 
Nested classes/interfaces inherited from interface org.compass.core.CompassQuery
CompassQuery.CompassSpanQuery, CompassQuery.SortDirection, CompassQuery.SortImplicitType, CompassQuery.SortPropertyType
 
Constructor Summary
DefaultCompassQuery(SearchEngineQuery searchEngineQuery, InternalCompassSession session)
           
 
Method Summary
 CompassQuery addSort(CompassQuery.SortImplicitType implicitType)
          Adds sorting on implicit types, which are not direct properties values.
 CompassQuery addSort(CompassQuery.SortImplicitType implicitType, CompassQuery.SortDirection direction)
          Adds sorting on implicit types, which are not direct properties values.
 CompassQuery addSort(String name)
          Adds sorting on the given property name.
 CompassQuery addSort(String name, CompassQuery.SortDirection direction)
          Adds sorting on the given property name.
 CompassQuery addSort(String name, CompassQuery.SortPropertyType type)
          Adds sorting on the given property name, and using the given property type.
 CompassQuery addSort(String name, CompassQuery.SortPropertyType type, CompassQuery.SortDirection direction)
          Adds sorting on the given property name, and using the given property type.
 Object clone()
          Clones the given query.
 long count()
          Returns the count of hits that match this query.
 long count(float minimumScore)
          Returns the count of hits that match this query and are higher than the given score.
 CompassQueryFilter getFilter()
          Returns the filter set using CompassQuery.setFilter(CompassQueryFilter).
 SearchEngineQuery getSearchEngineQuery()
           
 CompassQuery getSuggestedQuery()
          Returns the suggested query (based on spell check).
 CompassHits hits()
          Performs the search and returns the hits that match the qeury.
 boolean isSuggested()
          Returns true if this is a suggested query.
 CompassQuery rewrite()
          Causes the query to be rewritten before executed to search.
 CompassQuery setAliases(String... aliases)
          Narrows down the query to be executed only against the given aliases.
 CompassQuery setBoost(float boost)
          Sets the boost for this query to boost.
 CompassQuery setFilter(CompassQueryFilter filter)
          Sets a filter to the query.
 CompassQuery setSubIndexes(String... subIndexes)
          Narrows down the query to be executed only against the given sub indexes.
 CompassQuery setTypes(Class... types)
          Narrows down the query to be executed only against the given types.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultCompassQuery

public DefaultCompassQuery(SearchEngineQuery searchEngineQuery,
                           InternalCompassSession session)
Method Detail

setBoost

public CompassQuery setBoost(float boost)
Description copied from interface: CompassQuery
Sets the boost for this query to boost. Hits matching this query will (in addition to the normal weightings) have their score multiplied by boost.

Specified by:
setBoost in interface CompassQuery

addSort

public CompassQuery addSort(String name)
Description copied from interface: CompassQuery
Adds sorting on the given property name. The type of sorting will be identified automatically (though it is preferable to specify it in advance using the CompassQuery.addSort(String,SortPropertyType).

Note that the property must be UN_TOKENIZED, and stored.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
name - The property name that will be sorted.

addSort

public CompassQuery addSort(String name,
                            CompassQuery.SortDirection direction)
Description copied from interface: CompassQuery
Adds sorting on the given property name. The type of sorting will be identified automatically (though it is preferable to specify it in advance using the CompassQuery.addSort(String,SortPropertyType).

Note that the property must be UN_TOKENIZED, and stored.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
name - The property name that will be sorted.
direction - The direction for the sorting.
Returns:
the query

addSort

public CompassQuery addSort(String name,
                            CompassQuery.SortPropertyType type)
Description copied from interface: CompassQuery
Adds sorting on the given property name, and using the given property type. Note that INT has the lowest memorty requirements and STRING the most.

Note that the property must be UN_TOKENIZED, and stored.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
name - The property name that will be sorted.
type - The type of the propert.
Returns:
the query

addSort

public CompassQuery addSort(String name,
                            CompassQuery.SortPropertyType type,
                            CompassQuery.SortDirection direction)
Description copied from interface: CompassQuery
Adds sorting on the given property name, and using the given property type. Note that INT has the lowest memorty requirements and STRING the most.

Note that the property must be UN_TOKENIZED, and stored.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
name - The property name that will be sorted.
type - The type of the propert.
direction - The direction of the sorting.
Returns:
the query

addSort

public CompassQuery addSort(CompassQuery.SortImplicitType implicitType)
Description copied from interface: CompassQuery
Adds sorting on implicit types, which are not direct properties values.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
implicitType - The implicit type to add sorting on.

addSort

public CompassQuery addSort(CompassQuery.SortImplicitType implicitType,
                            CompassQuery.SortDirection direction)
Description copied from interface: CompassQuery
Adds sorting on implicit types, which are not direct properties values.

Note, that the sort option will only work on the outer most query (i.e. the one that the hits is called on).

Specified by:
addSort in interface CompassQuery
Parameters:
implicitType - The implicit type to add sorting on.
direction - The direction of the sorting.

setSubIndexes

public CompassQuery setSubIndexes(String... subIndexes)
Description copied from interface: CompassQuery
Narrows down the query to be executed only against the given sub indexes. If set to null, will use all sub indexes.

Specified by:
setSubIndexes in interface CompassQuery
Parameters:
subIndexes - sub indexes the query will be executed against
Returns:
The query

setAliases

public CompassQuery setAliases(String... aliases)
Description copied from interface: CompassQuery
Narrows down the query to be executed only against the given aliases. If set to null, will use all aliases.

Specified by:
setAliases in interface CompassQuery
Parameters:
aliases - aliases the query will be executed against
Returns:
th query

setTypes

public CompassQuery setTypes(Class... types)
Description copied from interface: CompassQuery
Narrows down the query to be executed only against the given types. Internally will translate the classes to the relevant root aliases and call CompassQuery.setAliases(String[]).

Specified by:
setTypes in interface CompassQuery
Parameters:
types - class types the query will be executed against
Returns:
the query

setFilter

public CompassQuery setFilter(CompassQueryFilter filter)
Description copied from interface: CompassQuery
Sets a filter to the query. Please see CompassQueryFilterBuilder.

Specified by:
setFilter in interface CompassQuery
Parameters:
filter - The filter for the query
Returns:
the query

getFilter

public CompassQueryFilter getFilter()
Description copied from interface: CompassQuery
Returns the filter set using CompassQuery.setFilter(CompassQueryFilter). null if none is set.

Specified by:
getFilter in interface CompassQuery
Returns:
The filter set using CompassQuery.setFilter(CompassQueryFilter)

rewrite

public CompassQuery rewrite()
Description copied from interface: CompassQuery
Causes the query to be rewritten before executed to search.

Specified by:
rewrite in interface CompassQuery

getSuggestedQuery

public CompassQuery getSuggestedQuery()
Description copied from interface: CompassQuery
Returns the suggested query (based on spell check). If spell check is disabled the same query is returned.

In order to know if the query was actually replaced with a suggested one, call CompassQuery.isSuggested().

Specified by:
getSuggestedQuery in interface CompassQuery

isSuggested

public boolean isSuggested()
Description copied from interface: CompassQuery
Returns true if this is a suggested query. For example, when performing a search query with spell check enabled, then it will return true if the query was modified to correct some spelling mistakes.

Specified by:
isSuggested in interface CompassQuery

count

public long count()
Description copied from interface: CompassQuery
Returns the count of hits that match this query. Note, this will be faster than CompassHitsOperations.length().

Same as calling count(0.0f).

Specified by:
count in interface CompassQuery

count

public long count(float minimumScore)
Description copied from interface: CompassQuery
Returns the count of hits that match this query and are higher than the given score. Note, this will be faster than CompassHitsOperations.length().

Specified by:
count in interface CompassQuery

hits

public CompassHits hits()
                 throws CompassException
Description copied from interface: CompassQuery
Performs the search and returns the hits that match the qeury.

Specified by:
hits in interface CompassQuery
Throws:
CompassException

getSearchEngineQuery

public SearchEngineQuery getSearchEngineQuery()

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: CompassQuery
Clones the given query.

Specified by:
clone in interface CompassQuery
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright (c) 2004-2008 The Compass Project.