Package org.alfresco.service.cmr.search
Class SearchParameters
java.lang.Object
org.alfresco.service.cmr.search.SearchParameters
- All Implemented Interfaces:
BasicSearchParameters
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
- Author:
- Andy Hind
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumstatic enumstatic enumAn emum defining if the default action is to "and" or "or" unspecified components in the query register.static classA helper class for sort definition. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA parameter that can be passed to Solr to indicate an alternative dictionary should be used.static final SearchParameters.OperatorANDstatic final SearchParameters.OperatorORstatic final SearchParameters.SortDefinitionSort in the order docs were added to the index - oldest docs firststatic final SearchParameters.SortDefinitionSort in the reverse order docs were added to the index - new/updateed docs firststatic final SearchParameters.SortDefinitionSort in ascending scorestatic final SearchParameters.SortDefinitionSort in descending score order -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorSearchParameters(QueryOptions options) Construct from Query Options -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllAttribute(String attribute) Add a field for ALL expansionvoidaddExtraParameter(String name, String value) voidaddFacetQuery(String facetQuery) voidaddFieldFacet(SearchParameters.FieldFacet fieldFacet) voidaddFilterQuery(String filterQuery) voidAdd a locale to include for multi-lingual text searches.voidvoidaddQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition) Add parameter definitions for the query - used to parameterise the query stringaddQueryTemplate(String name, String template) Add/replace a query template Not all languages support query templatesvoidAdd 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.voidaddSort(SearchParameters.SortDefinition sortDefinition) Add a sort definition.voidSet the stores to be supported - currently there can be only one.voidaddTextAttribute(String attribute) Add a field for TEXT expansioncopy()booleanbooleanIs data in the current transaction excluded from the search.voidexcludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction) If true, any data in the current transaction will be ignored in the search.Get the text attributes used for ALL expansion.As getDefaultFTSConnective() but for field groupsGet the default connective used when OR and AND are not specified for the FTS contains() function.Get the default operator for query elements when they are not explicit in the query.booleanGets the parameters used for search highlighingGet the search languageintgetLimit()If limiting the result set in some way, get the limiting value used.Get how the result set should be limitedGet the locales used for multi-lingual text searches.intGet the max number of rows for the result set 0 or less is unlimitedintlongThe way in which multilingual fields are treated durig a search.Get the default namespace.Get when permissions are evaluated.getQuery()Get the query.Get the query parameters that apply to this query.Get the query templatesIf not null, then the search should only include results from transactions aftersinceTxId.intGet the skip count - the number of rows to skip at the start of the query.Get the sort definitions that apply to this query.getStats()Get the stores in which this query should find results.Get the text attributes used for text expansion.intbooleanChecks if faceting is used as part of the query, Search-347.inthashCode()booleanbooleanbooleanvoidsetBulkFetchEnabled(boolean isBulkFetchEnabled) voidsetDefaultFieldName(String defaultFieldName) voidsetDefaultFTSFieldConnective(SearchParameters.Operator defaultFTSFieldOperator) As setDefaultFTSConnective() but for field groupsvoidsetDefaultFTSOperator(SearchParameters.Operator defaultFTSOperator) Set the default connective used when OR and AND are not specified for the FTS contains() function.voidsetDefaultOperator(SearchParameters.Operator defaultOperator) Set the default operator for query elements when they are not explicit in the query.voidsetExcludeTenantFilter(boolean excludeTenantFilter) voidsetHighlight(GeneralHighlightParameters highlight) Sets parameters used for search highlighingvoidsetIncludeMetadata(boolean includeMetadata) voidsetInterval(IntervalParameters interval) Sets parameters used for IntervalsvoidsetLanguage(String language) Set the query language.voidsetLimit(int limit) If limiting the result set in some way, set the limiting value used.voidsetLimitBy(LimitBy limitBy) Set how the result set should be limited.voidsetMaxItems(int maxItems) Set the max number of rows for the result set.voidsetMaxPermissionChecks(int maxPermissionChecks) voidsetMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis) voidsetMaxRawResultSetSizeForInMemorySort(Integer maxRawResultSetSizeForInMemorySort) voidsetMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode) Set the way in which multilingual fields are treated durig a search.voidsetNamespace(String namespace) Set the default namespacevoidsetPermissionEvaluation(PermissionEvaluationMode permissionEvaluation) Set when permissions are evaluated.voidSet the query string.voidsetQueryConsistency(QueryConsistency queryConsistency) voidsetRanges(List<RangeParameters> ranges) voidsetSearchTerm(String searchTerm) voidsetSinceTxId(Long sinceTxId) If not null, then the search should only include results from transactions aftersinceTxId.voidsetSkipCount(int skipCount) Set the skip count - the number of rows to skip at the start of the query.voidsetSpellCheck(boolean spellCheck) voidsetStats(List<StatsRequestParameters> stats) voidsetTimezone(String timezone) Override the default TimeZone (UTC)voidsetTrackTotalHits(int trackTotalHits) Set a maximum value for the report of total hits.voidsetUseInMemorySort(Boolean useInMemorySort) toString()booleanusePostSort(int length, boolean useInMemorySortDefault, int maxRawResultSetSizeForInMemorySortDefault)
-
Field Details
-
SORT_IN_DOCUMENT_ORDER_ASCENDING
Sort in the order docs were added to the index - oldest docs first -
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
Sort in ascending score -
SORT_IN_SCORE_ORDER_DESCENDING
Sort in descending score order -
OR
OR -
AND
AND -
ALTERNATIVE_DICTIONARY
A parameter that can be passed to Solr to indicate an alternative dictionary should be used.- See Also:
-
-
Constructor Details
-
SearchParameters
public SearchParameters()Default constructor -
SearchParameters
Construct from Query Options- Parameters:
options- QueryOptions
-
-
Method Details
-
copy
-
getLanguage
Get the search language- Specified by:
getLanguagein interfaceBasicSearchParameters- Returns:
- - string id of search language
-
getQuery
Get the query.- Specified by:
getQueryin interfaceBasicSearchParameters- Returns:
- - the query string
-
setHighlight
Sets parameters used for search highlighing- Parameters:
highlight- GeneralHighlightParameters
-
getStats
-
setStats
-
getInterval
-
setInterval
Sets parameters used for Intervals- Parameters:
interval- IntervalParameters
-
getRanges
-
setRanges
-
setLanguage
Set the query language.- Parameters:
language- - the query language.
-
getTimezone
-
setTimezone
Override the default TimeZone (UTC)- Parameters:
timezone- any zone ID supported by @see java.time.ZoneId
-
addExtraParameter
-
getExtraParameters
-
setQuery
Set the query string.- Parameters:
query- - the query string.
-
addStore
Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo list.- Parameters:
store- StoreRef
-
addQueryParameterDefinition
Add parameter definitions for the query - used to parameterise the query string- Parameters:
queryParameterDefinition- 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- boolean
-
addSort
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
Add a sort definition.- Parameters:
sortDefinition- - the sort definition to add. Use the static member variables for sorting in score and index order.
-
getHighlight
Gets the parameters used for search highlighing- Returns:
- GeneralHighlightParameters - the highlighting parameters
-
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
Get the query parameters that apply to this query.- Returns:
- - the parameter
-
getSortDefinitions
Get the sort definitions that apply to this query.- Specified by:
getSortDefinitionsin interfaceBasicSearchParameters- Returns:
- - the sort definitions
-
getStores
Get the stores in which this query should find results.- Specified by:
getStoresin interfaceBasicSearchParameters- Returns:
- - the list of stores
-
setDefaultOperator
Set the default operator for query elements when they are not explicit in the query.- Parameters:
defaultOperator- Operator
-
getDefaultOperator
Get the default operator for query elements when they are not explicit in the query.- Returns:
- the default operator
-
getLimitBy
Get how the result set should be limited- Returns:
- how the result set will be or was limited
-
setLimitBy
Set how the result set should be limited.- Parameters:
limitBy- LimitBy
-
getPermissionEvaluation
Get when permissions are evaluated.- Returns:
- - how permissions are evaluated
-
setPermissionEvaluation
Set when permissions are evaluated.- Parameters:
permissionEvaluation- PermissionEvaluationMode
-
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- int
-
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
Set the way in which multilingual fields are treated durig a search. This controls in which locales an multilingual fields will match.- Parameters:
mlAnalaysisMode- MLAnalysisMode
-
addLocale
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- Locale
-
getLocales
Get the locales used for multi-lingual text searches.- Specified by:
getLocalesin interfaceBasicSearchParameters- Returns:
- - the locales
-
addTextAttribute
Add a field for TEXT expansion- Parameters:
attribute- - field/attribute in the index
-
getTextAttributes
Get the text attributes used for text expansion.- Returns:
- the text attributes used for text expansion
-
addAllAttribute
Add a field for ALL expansion- Parameters:
attribute- - field/attribute in the index
-
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
Get the default connective used when OR and AND are not specified for the FTS contains() function.- Returns:
- the defaultFTSConnective
-
setDefaultFTSOperator
Set the default connective used when OR and AND are not specified for the FTS contains() function.- Parameters:
defaultFTSOperator- the defaultFTSOperator to set
-
getDefaultFTSFieldOperator
As getDefaultFTSConnective() but for field groups- Returns:
- the defaultFTSFieldConnective
-
setDefaultFTSFieldConnective
As setDefaultFTSConnective() but for field groups- Parameters:
defaultFTSFieldOperator- the defaultFTSFieldOperator to set
-
getNamespace
Get the default namespace.- Returns:
- the default namspace uri or prefix.
-
setNamespace
Set the default namespace- Parameters:
namespace- - the uri or prefix for the default namespace.
-
getQueryTemplates
Get the query templates- Returns:
- - the query templates
-
addQueryTemplate
Add/replace a query template Not all languages support query templates- Parameters:
name- Stringtemplate- String- 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) -
getUseInMemorySort
- Returns:
- the useInMemorySort
-
setUseInMemorySort
- Parameters:
useInMemorySort- the useInMemorySort to set
-
getMaxRawResultSetSizeForInMemorySort
- Returns:
- the maxRawResultSetSizeForInMemorySort
-
setMaxRawResultSetSizeForInMemorySort
- Parameters:
maxRawResultSetSizeForInMemorySort- the maxRawResultSetSizeForInMemorySort to set
-
isBulkFetchEnabled
public boolean isBulkFetchEnabled()- Returns:
- true if bulk fetch is enabled
-
setBulkFetchEnabled
public void setBulkFetchEnabled(boolean isBulkFetchEnabled) - Parameters:
isBulkFetchEnabled- boolean
-
getDefaultFieldName
- Returns:
- the default field name
-
setDefaultFieldName
- Parameters:
defaultFieldName- - the default field name to use
-
getFieldFacets
-
addFieldFacet
-
getFacetQueries
-
addFacetQuery
-
getFilterQueries
-
addFilterQuery
-
getPivots
-
addPivots
-
getSortLocale
-
setExcludeTenantFilter
public void setExcludeTenantFilter(boolean excludeTenantFilter) -
getExcludeTenantFilter
public boolean getExcludeTenantFilter() -
setQueryConsistency
-
getQueryConsistency
- Returns:
- the queryConsistency
-
getSinceTxId
If not null, then the search should only include results from transactions aftersinceTxId.- Returns:
- sinceTxId
-
setSinceTxId
If not null, then the search should only include results from transactions aftersinceTxId.- Parameters:
sinceTxId- Long
-
getSearchTerm
- Returns:
- the searchTerm
-
setSearchTerm
- Parameters:
searchTerm- the searchTerm to set
-
isSpellCheck
public boolean isSpellCheck()- Returns:
- the spellCheck
-
hasFaceting
public boolean hasFaceting()Checks if faceting is used as part of the query, Search-347.- Parameters:
searchParameters-- Returns:
- true if exists
-
setSpellCheck
public void setSpellCheck(boolean spellCheck) - Parameters:
spellCheck- the spellCheck to set
-
hashCode
public int hashCode() -
equals
-
toString
-
toAuditString
-
usePostSort
public boolean usePostSort(int length, boolean useInMemorySortDefault, int maxRawResultSetSizeForInMemorySortDefault) - Parameters:
length- intuseInMemorySortDefault- booleanmaxRawResultSetSizeForInMemorySortDefault- int- Returns:
- boolean
-
isIncludeMetadata
public boolean isIncludeMetadata() -
setIncludeMetadata
public void setIncludeMetadata(boolean includeMetadata) -
getTrackTotalHits
public int getTrackTotalHits() -
setTrackTotalHits
public void setTrackTotalHits(int trackTotalHits) Set a maximum value for the report of total hits. The reported number of hits will never exceed this limit even if more are found. If unset, the engine’s default tracking limit is applied. To remove any limit, set to -1.- Parameters:
trackTotalHits- int
-