org.alfresco.service.cmr.search
Class SearchParameters

java.lang.Object
  extended by org.alfresco.service.cmr.search.SearchParameters

public class SearchParameters
extends java.lang.Object

This class provides parameters to define a search. TODO - paging of results page number and page size - paging isolation - REPEATABLE READ, READ COMMITTED, may SEE ONCE tracking node refs in previous result sets - how long repeatable read may be held - limit by the number of permission evaluations


Nested Class Summary
static class SearchParameters.FieldFacet
           
static class SearchParameters.FieldFacetMethod
           
static class SearchParameters.FieldFacetSort
           
static class SearchParameters.Operator
          An emum defining if the default action is to "and" or "or" unspecified components in the query register.
static class SearchParameters.SortDefinition
          A helper class for sort definition.
 
Field Summary
static SearchParameters.Operator AND
          AND
static SearchParameters.Operator OR
          OR
static SearchParameters.SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING
          Sort in the order docs were added to the index - oldest docs first
static SearchParameters.SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING
          Sort in the reverse order docs were added to the index - new/updateed docs first
static SearchParameters.SortDefinition SORT_IN_SCORE_ORDER_ASCENDING
          Sort in ascending score
static SearchParameters.SortDefinition SORT_IN_SCORE_ORDER_DESCENDING
          Sort in descending score order
 
Constructor Summary
SearchParameters()
          Default constructor
SearchParameters(QueryOptions options)
          Construct from Query Options
 
Method Summary
 void addAllAttribute(java.lang.String attribute)
          Add a field for ALL expansion
 void addFieldFacet(SearchParameters.FieldFacet fieldFacet)
           
 void addLocale(java.util.Locale locale)
          Add a locale to include for multi-lingual text searches.
 void addQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition)
          Add parameter definitions for the query - used to parameterise the query string
 java.lang.String addQueryTemplate(java.lang.String name, java.lang.String template)
          Add/replace a query template Not all languages support query templates
 void addSort(SearchParameters.SortDefinition sortDefinition)
          Add a sort definition.
 void addSort(java.lang.String field, boolean ascending)
          Add a sort to the query (for those query languages that do not support it directly) The first sort added is treated as primary, the second as secondary etc.
 void addStore(StoreRef store)
          Set the stores to be supported - currently there can be only one.
 void addTextAttribute(java.lang.String attribute)
          Add a field for TEXT expansion
 boolean equals(java.lang.Object obj)
           
 boolean excludeDataInTheCurrentTransaction()
          Is data in the current transaction excluded from the search.
 void excludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction)
          If true, any data in the current transaction will be ignored in the search.
 java.util.Set getAllAttributes()
          Get the text attributes used for ALL expansion.
 java.lang.String getDefaultFieldName()
           
 SearchParameters.Operator getDefaultFTSFieldOperator()
          As getDefaultFTSConnective() but for field groups
 SearchParameters.Operator getDefaultFTSOperator()
          Get the default connective used when OR and AND are not specified for the FTS contains() function.
 SearchParameters.Operator getDefaultOperator()
          Get the default operator for query elements when they are not explicit in the query.
 java.util.List getFieldFacets()
           
 java.lang.String getLanguage()
          Get the search language
 int getLimit()
          If limiting the result set in some way, get the limiting value used.
 LimitBy getLimitBy()
          Get how the result set should be limited
 java.util.List getLocales()
          Get the locales used for multi-lingual text searches.
 int getMaxItems()
          Get the max number of rows for the result set 0 or less is unlimited
 int getMaxPermissionChecks()
           
 long getMaxPermissionCheckTimeMillis()
           
 MLAnalysisMode getMlAnalaysisMode()
          The way in which multilingual fields are treated durig a search.
 java.lang.String getNamespace()
          Get the default namespace.
 PermissionEvaluationMode getPermissionEvaluation()
          Get when permissions are evaluated.
 java.lang.String getQuery()
          Get the query.
 java.util.ArrayList getQueryParameterDefinitions()
          Get the query parameters that apply to this query.
 java.util.Map getQueryTemplates()
          Get the query templates
 int getSkipCount()
          Get the skip count - the number of rows to skip at the start of the query.
 java.util.ArrayList getSortDefinitions()
          Get the sort definitions that apply to this query.
 java.util.ArrayList getStores()
          Get the stores in which this query should find results.
 java.util.Set getTextAttributes()
          Get the text attributes used for text expansion.
 int hashCode()
           
 void setDefaultFieldName(java.lang.String defaultFieldName)
           
 void setDefaultFTSFieldConnective(SearchParameters.Operator defaultFTSFieldOperator)
          As setDefaultFTSConnective() but for field groups
 void setDefaultFTSOperator(SearchParameters.Operator defaultFTSOperator)
          Set the default connective used when OR and AND are not specified for the FTS contains() function.
 void setDefaultOperator(SearchParameters.Operator defaultOperator)
          Set the default operator for query elements when they are not explicit in the query.
 void setLanguage(java.lang.String language)
          Set the query language.
 void setLimit(int limit)
          If limiting the result set in some way, set the limiting value used.
 void setLimitBy(LimitBy limitBy)
          Set how the result set should be limited.
 void setMaxItems(int maxItems)
          Set the max number of rows for the result set.
 void setMaxPermissionChecks(int maxPermissionChecks)
           
 void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)
           
 void setMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode)
          Set the way in which multilingual fields are treated durig a search.
 void setNamespace(java.lang.String namespace)
          Set the default namespace
 void setPermissionEvaluation(PermissionEvaluationMode permissionEvaluation)
          Set when permissions are evaluated.
 void setQuery(java.lang.String query)
          Set the query string.
 void setSkipCount(int skipCount)
          Set the skip count - the number of rows to skip at the start of the query.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SORT_IN_DOCUMENT_ORDER_ASCENDING

public static final SearchParameters.SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING
Sort in the order docs were added to the index - oldest docs first


SORT_IN_DOCUMENT_ORDER_DESCENDING

public static final SearchParameters.SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING
Sort in the reverse order docs were added to the index - new/updateed docs first


SORT_IN_SCORE_ORDER_ASCENDING

public static final SearchParameters.SortDefinition SORT_IN_SCORE_ORDER_ASCENDING
Sort in ascending score


SORT_IN_SCORE_ORDER_DESCENDING

public static final SearchParameters.SortDefinition SORT_IN_SCORE_ORDER_DESCENDING
Sort in descending score order


OR

public static final SearchParameters.Operator OR
OR


AND

public static final SearchParameters.Operator AND
AND

Constructor Detail

SearchParameters

public SearchParameters()
Default constructor


SearchParameters

public SearchParameters(QueryOptions options)
Construct from Query Options

Parameters:
options -
Method Detail

getLanguage

public java.lang.String getLanguage()
Get the search language

Returns:
- string id of search language

getQuery

public java.lang.String getQuery()
Get the query.

Returns:
- the query string

setLanguage

public void setLanguage(java.lang.String language)
Set the query language.

Parameters:
language - - the query language.

setQuery

public void setQuery(java.lang.String query)
Set the query string.

Parameters:
query - - the query string.

addStore

public void addStore(StoreRef store)
Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo list.

Parameters:
store -

addQueryParameterDefinition

public void addQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition)
Add parameter definitions for the query - used to parameterise the query string

Parameters:
queryParameterDefinition -

excludeDataInTheCurrentTransaction

public void excludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction)
If true, any data in the current transaction will be ignored in the search. You will not see anything you have added in the current transaction. By default you will see data in the current transaction. This effectively gives read committed isolation. There is a performance overhead for this, at least when using lucene. This flag may be set to avoid that performance hit if you know you do not want to find results that are yet to be committed (this includes creations, deletions and updates)

Parameters:
excludeDataInTheCurrentTransaction -

addSort

public void addSort(java.lang.String field,
                    boolean ascending)
Add a sort to the query (for those query languages that do not support it directly) The first sort added is treated as primary, the second as secondary etc. A helper method to create SortDefinitions.

Parameters:
field - - this is initially a direct attribute on a node not an attribute on the parent etc TODO: It could be a relative path at some time.
ascending - - true to sort ascending, false for descending.

addSort

public void addSort(SearchParameters.SortDefinition sortDefinition)
Add a sort definition.

Parameters:
sortDefinition - - the sort definition to add. Use the static member variables for sorting in score and index order.

excludeDataInTheCurrentTransaction

public boolean excludeDataInTheCurrentTransaction()
Is data in the current transaction excluded from the search.

Returns:
- true if data in the current transaction is ignored

getQueryParameterDefinitions

public java.util.ArrayList getQueryParameterDefinitions()
Get the query parameters that apply to this query.

Returns:
- the parameter

getSortDefinitions

public java.util.ArrayList getSortDefinitions()
Get the sort definitions that apply to this query.

Returns:
- the sort definitions

getStores

public java.util.ArrayList getStores()
Get the stores in which this query should find results.

Returns:
- the list of stores

setDefaultOperator

public void setDefaultOperator(SearchParameters.Operator defaultOperator)
Set the default operator for query elements when they are not explicit in the query.

Parameters:
defaultOperator -

getDefaultOperator

public SearchParameters.Operator getDefaultOperator()
Get the default operator for query elements when they are not explicit in the query.

Returns:
the default operator

getLimitBy

public LimitBy getLimitBy()
Get how the result set should be limited

Returns:
how the result set will be or was limited

setLimitBy

public void setLimitBy(LimitBy limitBy)
Set how the result set should be limited.

Parameters:
limitBy -

getPermissionEvaluation

public PermissionEvaluationMode getPermissionEvaluation()
Get when permissions are evaluated.

Returns:
- how permissions are evaluated

setPermissionEvaluation

public void setPermissionEvaluation(PermissionEvaluationMode permissionEvaluation)
Set when permissions are evaluated.

Parameters:
permissionEvaluation -

getLimit

public int getLimit()
If limiting the result set in some way, get the limiting value used.

Returns:
the limit

setLimit

public void setLimit(int limit)
If limiting the result set in some way, set the limiting value used.

Parameters:
limit -

getMlAnalaysisMode

public MLAnalysisMode getMlAnalaysisMode()
The way in which multilingual fields are treated durig a search. By default, only the specified locale is used and it must be an exact match.

Returns:
- how locale related text is tokenised

setMlAnalaysisMode

public void setMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode)
Set the way in which multilingual fields are treated durig a search. This controls in which locales an multilingual fields will match.

Parameters:
mlAnalaysisMode -

addLocale

public void addLocale(java.util.Locale locale)
Add a locale to include for multi-lingual text searches. If non are set, the default is to use the user's locale.

Parameters:
locale -

getLocales

public java.util.List getLocales()
Get the locales used for multi-lingual text searches.

Returns:
- the locales

addTextAttribute

public void addTextAttribute(java.lang.String attribute)
Add a field for TEXT expansion

Parameters:
attribute - - field/attribute in the index

getTextAttributes

public java.util.Set getTextAttributes()
Get the text attributes used for text expansion.

Returns:
the text attributes used for text expansion

addAllAttribute

public void addAllAttribute(java.lang.String attribute)
Add a field for ALL expansion

Parameters:
attribute - - field/attribute in the index

getAllAttributes

public java.util.Set getAllAttributes()
Get the text attributes used for ALL expansion.

Returns:
the text attributes used for ALL expansion

getMaxItems

public int getMaxItems()
Get the max number of rows for the result set 0 or less is unlimited

Returns:
the maxItems

setMaxItems

public void setMaxItems(int maxItems)
Set the max number of rows for the result set. A negative value implies unlimited 0 will return no results.

Parameters:
maxItems - the maxItems to set

getSkipCount

public int getSkipCount()
Get the skip count - the number of rows to skip at the start of the query.

Returns:
the skipCount

setSkipCount

public void setSkipCount(int skipCount)
Set the skip count - the number of rows to skip at the start of the query.

Parameters:
skipCount - the skipCount to set

getDefaultFTSOperator

public SearchParameters.Operator getDefaultFTSOperator()
Get the default connective used when OR and AND are not specified for the FTS contains() function.

Returns:
the defaultFTSConnective

setDefaultFTSOperator

public void setDefaultFTSOperator(SearchParameters.Operator defaultFTSOperator)
Set the default connective used when OR and AND are not specified for the FTS contains() function.

Parameters:
defaultFTSOperator - the defaultFTSOperator to set

getDefaultFTSFieldOperator

public SearchParameters.Operator getDefaultFTSFieldOperator()
As getDefaultFTSConnective() but for field groups

Returns:
the defaultFTSFieldConnective

setDefaultFTSFieldConnective

public void setDefaultFTSFieldConnective(SearchParameters.Operator defaultFTSFieldOperator)
As setDefaultFTSConnective() but for field groups

Parameters:
defaultFTSFieldOperator - the defaultFTSFieldOperator to set

getNamespace

public java.lang.String getNamespace()
Get the default namespace.

Returns:
the default namspace uri or prefix.

setNamespace

public void setNamespace(java.lang.String namespace)
Set the default namespace

Parameters:
namespace - - the uri or prefix for the default namespace.

getQueryTemplates

public java.util.Map getQueryTemplates()
Get the query templates

Returns:
- the query templates

addQueryTemplate

public java.lang.String addQueryTemplate(java.lang.String name,
                                         java.lang.String template)
Add/replace a query template Not all languages support query templates

Parameters:
name -
template -
Returns:
any removed template or null

getMaxPermissionCheckTimeMillis

public long getMaxPermissionCheckTimeMillis()

setMaxPermissionCheckTimeMillis

public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)

getMaxPermissionChecks

public int getMaxPermissionChecks()

setMaxPermissionChecks

public void setMaxPermissionChecks(int maxPermissionChecks)

getDefaultFieldName

public java.lang.String getDefaultFieldName()
Returns:
the default field name

setDefaultFieldName

public void setDefaultFieldName(java.lang.String defaultFieldName)
Parameters:
defaultFieldName - - the default field name to use

getFieldFacets

public java.util.List getFieldFacets()

addFieldFacet

public void addFieldFacet(SearchParameters.FieldFacet fieldFacet)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.