org.compass.core
Interface CompassQuery

All Known Subinterfaces:
CompassQuery.CompassSpanQuery
All Known Implementing Classes:
DefaultCompassQuery, DefaultCompassQuery.DefaultCompassSpanQuey

public interface CompassQuery

An object representing a Compass query. The query is created using the CompassQueryBuilder, and used to get the matching CompassHits.

The query be sorted as well using one of the addSort operations. Note that adding sorting is only applicable for the query that will execute the hits() operation.

Author:
kimchy

Nested Class Summary
static interface CompassQuery.CompassSpanQuery
          An extension to the CompassQuery interface.
static class CompassQuery.SortDirection
          Used to set the sort direction for the query.
static class CompassQuery.SortImplicitType
          Implicit types that the hits can be sorted by.
static class CompassQuery.SortPropertyType
          Used to define the type of the property that will be sorted.
 
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 propertyName)
          Adds sorting on the given property name.
 CompassQuery addSort(String propertyName, CompassQuery.SortDirection direction)
          Adds sorting on the given property name.
 CompassQuery addSort(String propertyName, CompassQuery.SortPropertyType type)
          Adds sorting on the given property name, and using the given property type.
 CompassQuery addSort(String propertyName, CompassQuery.SortPropertyType type, CompassQuery.SortDirection direction)
          Adds sorting on the given property name, and using the given property type.
 CompassQueryFilter getFilter()
          Returns the filter set using setFilter(CompassQueryFilter).
 CompassHits hits()
          Performs the search and returns the hits that match the qeury.
 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.
 

Method Detail

setBoost

CompassQuery setBoost(float boost)
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.


addSort

CompassQuery addSort(String propertyName)
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 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).

Parameters:
propertyName - The property name that will be sorted.

addSort

CompassQuery addSort(String propertyName,
                     CompassQuery.SortDirection direction)
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 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).

Parameters:
propertyName - The property name that will be sorted.
direction - The direction for the sorting.
Returns:
the query

addSort

CompassQuery addSort(String propertyName,
                     CompassQuery.SortPropertyType type)
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).

Parameters:
propertyName - The property name that will be sorted.
type - The type of the propert.
Returns:
the query

addSort

CompassQuery addSort(String propertyName,
                     CompassQuery.SortPropertyType type,
                     CompassQuery.SortDirection direction)
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).

Parameters:
propertyName - The property name that will be sorted.
type - The type of the propert.
direction - The direction of the sorting.
Returns:
the query

addSort

CompassQuery addSort(CompassQuery.SortImplicitType implicitType)
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).

Parameters:
implicitType - The implicit type to add sorting on.

addSort

CompassQuery addSort(CompassQuery.SortImplicitType implicitType,
                     CompassQuery.SortDirection direction)
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).

Parameters:
implicitType - The implicit type to add sorting on.
direction - The direction of the sorting.

setSubIndexes

CompassQuery setSubIndexes(String[] subIndexes)
Narrows down the query to be executed only against the given sub indexes. If set to null, will use all sub indexes.

Parameters:
subIndexes - sub indexes the query will be executed against
Returns:
The query

setAliases

CompassQuery setAliases(String[] aliases)
Narrows down the query to be executed only against the given aliases. If set to null, will use all sub indexes.

Parameters:
aliases - aliases the query will be executed against
Returns:
thr query

setFilter

CompassQuery setFilter(CompassQueryFilter filter)
Sets a filter to the query. Please see CompassQueryFilterBuilder.

Parameters:
filter - The filter for the query
Returns:
the query

getFilter

CompassQueryFilter getFilter()
Returns the filter set using setFilter(CompassQueryFilter). null if none is set.

Returns:
The filter set using setFilter(CompassQueryFilter)

hits

CompassHits hits()
                 throws CompassException
Performs the search and returns the hits that match the qeury.

Throws:
CompassException


Copyright (c) 2004-2006 The Compass Project.