public class SearchQuery extends AbstractQuery<SearchQuery,SearchParameter> implements java.lang.Cloneable
The SearchQuery can be configured using the various setters, or by setting the parameters yourself.
Each query contains several parameters, specified as name/value pairs. Several parameters can have the same name.
To execute a search, use a SearchClient that can be obtained through the SearchClientFactory
SearchClient
Modifier and Type | Field and Description |
---|---|
protected SearchAPIVersion |
version |
p
Constructor and Description |
---|
SearchQuery() |
SearchQuery(java.lang.String query) |
Modifier and Type | Method and Description |
---|---|
void |
addCategoryGroup(java.lang.String name,
java.lang.String root,
java.lang.String directory,
boolean inHits,
java.lang.Integer maxCategories,
java.lang.Integer maxCategoryTreeDepth,
java.lang.Integer maxCategoriesPerLevel,
java.lang.String sortFunction)
Deprecated.
Use CloudViewV6R2012XFacetingQueryBuilder
|
protected SearchQuery |
addMetaFromField(java.lang.String metaName,
java.lang.String indexField,
boolean highlighting,
boolean summary,
java.lang.Integer maxLength)
Deprecated.
Use CloudViewV6R2012XHitsQueryBuilder
|
SearchQuery |
addMetaFromField(java.lang.String metaName,
java.lang.String indexField,
boolean highlighting,
java.lang.Integer maxLength)
Deprecated.
Use CloudViewV6R2012XHitsQueryBuilder
|
void |
addMetasFromCSVField(java.lang.String[] metaNames,
java.lang.String indexField,
java.lang.String[] originalNames,
boolean highlighting,
java.lang.Integer maxLength)
Deprecated.
Use CloudViewV6R2012XHitsQueryBuilder
|
SearchQuery |
addParameter(java.lang.String name,
java.lang.String value)
Adds a search parameter which is composed by a name and a value.
|
SearchQuery |
addRefinement(java.lang.String refId,
boolean excluded)
Adds a refinement
|
SearchQuery |
addSecurityToken(java.lang.String token)
Adds a security token
|
SearchQuery |
addSummaryMetaFromField(java.lang.String metaName,
java.lang.String indexField,
boolean highlighting,
java.lang.Integer maxLength)
Deprecated.
Use CloudViewV6R2012XHitsQueryBuilder
|
void |
addVirtualField(java.lang.String name,
java.lang.String expression)
Add a virtual expression which can be used for relevance, faceting, or hits
|
SearchQuery |
cancelRefinement(java.lang.String refId)
Removes a refinement from the list of refinements.
|
java.lang.Object |
clone() |
java.lang.String[] |
getCheckpoints()
Gets the list of requested checkpoints
|
int |
getClientTimeoutMS() |
java.lang.String |
getCollapsing()
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
java.lang.Integer |
getFullHits()
Returns the number of results that will be retrieved
|
java.lang.String |
getLanguage()
Returns the query language
|
SearchParameter[] |
getParameters()
Return the list of all parameters
|
java.lang.String |
getQuery()
Returns the query string
|
java.lang.String[] |
getRefinements()
Returns the current refinements
|
int |
getResultsSetLength()
Deprecated.
|
int |
getResultsSetStart() |
java.lang.String |
getSearchContext()
Returns the search context (if it has been set)
|
java.lang.String |
getSearchLogic()
Returns the logic (default query) that will be used
|
java.lang.String[] |
getSecurityTokens()
Returns the current security tokens
|
java.lang.String |
getSortField()
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
java.lang.String |
getTarget()
Returns the target
|
SearchAPIVersion |
getTargetVersion() |
java.lang.Integer |
getTimeout()
Deprecated.
Use CloudView52LimitsQueryBuilder
|
boolean |
isSortAscending()
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
SearchQuery |
removeCategoryGroup(java.lang.String name)
Deprecated.
Use CloudViewV6R2012XFacetingQueryBuilder
|
SearchQuery |
removeMeta(java.lang.String metaName)
Deprecated.
|
SearchQuery |
removeParameter(java.lang.String name)
Removes the parameter(s) with the given name
If several parameters have the same name they will all be removed
|
SearchQuery |
removeSecurityToken(java.lang.String token)
Removes a security token from the list of
security tokens
|
void |
removeVirtualField(java.lang.String name)
Note that only the virtual field definition will be removed, if the field is retrieved as the meta,
the meta must be also be removed.
|
void |
setAscendingSort(boolean isAscending)
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
SearchQuery |
setCheckpoints(java.lang.String checkpoints)
Sets the checkpoints to retrieve
|
SearchQuery |
setCheckpoints(java.lang.String[] checkpoints)
Sets the checkpoints to retrieve
|
void |
setClientTimeoutMS(int clientTimeoutMS) |
SearchQuery |
setCollapsing(boolean lsb,
boolean msb)
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
SearchQuery |
setEnforceSecurity(boolean enforce) |
SearchQuery |
setFullHits(int length)
Sets the number of results that will be retrieved
|
SearchQuery |
setLanguage(java.lang.String lang)
Sets the query language
|
SearchQuery |
setParameter(java.lang.String name,
java.lang.String value)
Set a search parameter on your query.
|
SearchQuery |
setQuery(java.lang.String query)
Sets the query string
Example: "exalead OR author:bourdoncle"
(see Query Language Guide for more details)
|
SearchQuery |
setResultsSetLength(int length)
Sets the number of results that will be retrieved
|
SearchQuery |
setResultsSetLength(long length)
Sets the number of results that will be retrieved
|
SearchQuery |
setResultsSetStart(int startIndex)
Set the index of the first result to retrieve
|
SearchQuery |
setResultsSetStart(long startIndex)
Set the index of the first result to retrieve
|
SearchQuery |
setSearchContext(java.lang.String context)
Sets the search context.
|
SearchQuery |
setSearchLogic(java.lang.String name)
Sets the logic (default query) that will be used
|
SearchQuery |
setSortField(java.lang.String fieldName)
Deprecated.
Use CloudView60RelevanceQueryBuilder
|
SearchQuery |
setSortField(java.lang.String fieldName,
boolean isSecondary)
Deprecated.
Use CloudViewV6R2012XRelevanceQueryBuilder
|
void |
setStaticRankingExpression(java.lang.String expression)
Deprecated.
Use CloudView60RelevanceQueryBuilder
|
SearchQuery |
setTarget(java.lang.String target)
Sets the search target
|
void |
setTargetVersion(SearchAPIVersion version) |
SearchQuery |
setTimeout(java.lang.Integer millis)
Deprecated.
Use CloudView52LimitsQueryBuilder
|
void |
unSetStaticRankingExpression()
Deprecated.
Use CloudView60RelevanceQueryBuilder
|
addParameter, buildRequest, getParameter, getParameters, getParametersList, getParametersList, getParameterValue, getParameterValues, removeParameter, toString
protected SearchAPIVersion version
public SearchQuery()
public SearchQuery(java.lang.String query)
public void setTargetVersion(SearchAPIVersion version)
public SearchAPIVersion getTargetVersion()
public int getClientTimeoutMS()
public void setClientTimeoutMS(int clientTimeoutMS)
public SearchQuery setQuery(java.lang.String query)
public java.lang.String getQuery()
public SearchQuery setLanguage(java.lang.String lang)
lang
- a langId (ex: "en", "fr")public java.lang.String getLanguage()
public SearchQuery setTarget(java.lang.String target)
target
- The Targetpublic java.lang.String getTarget()
public SearchQuery setResultsSetStart(int startIndex)
startIndex
- index of the first result (starts from 0)public SearchQuery setResultsSetStart(long startIndex)
startIndex
- index of the first result (starts from 0)public int getResultsSetStart()
public SearchQuery setResultsSetLength(int length)
setFullHits}
public SearchQuery setResultsSetLength(long length)
setFullHits}
@Deprecated public int getResultsSetLength()
getFullHits}
public SearchQuery setFullHits(int length)
public java.lang.Integer getFullHits()
public SearchQuery setSearchLogic(java.lang.String name)
name
- a logic name (5.0) or query name (4.6)public java.lang.String getSearchLogic()
public SearchQuery setSearchContext(java.lang.String context)
This context is available in the Answer (via getContext)
and in the SearchAnswer via SearchAnswer.getInfos()
, (the key is "context")
The search context allows to chain queries easily without having to keep the parameters used in the previous queries.
Answer.getContext()
,
SearchAnswer.getInfos()
,
setSearchContext(String)
public java.lang.String getSearchContext()
public java.lang.String[] getRefinements()
Excluded refinements are prefixed with "-" others are prefixed with "+"
public SearchQuery setCheckpoints(java.lang.String checkpoints)
checkpoints
- String of comma separated checkpointspublic SearchQuery setCheckpoints(java.lang.String[] checkpoints)
public java.lang.String[] getCheckpoints()
public SearchQuery addParameter(java.lang.String name, java.lang.String value)
addParameter
in class AbstractQuery<SearchQuery,SearchParameter>
name
- the name of the search parameter. null is not acceptable.value
- the value of the search parameter. null is not acceptable.public SearchQuery removeParameter(java.lang.String name)
removeParameter
in class AbstractQuery<SearchQuery,SearchParameter>
public SearchQuery setParameter(java.lang.String name, java.lang.String value)
setParameter
in class AbstractQuery<SearchQuery,SearchParameter>
name
- : search parameter nameaddParameter
public SearchQuery addRefinement(java.lang.String refId, boolean excluded)
A refinement is way to precise your query by adding restriction to a set of categories related terms. A refinement can be a selection or an exclusion of a category (or related term).
refId
- the id of a category or related term Category.getId()
, RelatedTerm.getId()
public SearchQuery cancelRefinement(java.lang.String refId)
refId
- the id of the refinement.public java.lang.String[] getSecurityTokens()
public SearchQuery addSecurityToken(java.lang.String token)
Security tokens are pushed by connectors thanks to the meta "security" When security token check is enabled on the search server, the documents must have the provided security tokens to be retrieved. Note that the token "EVERYBODY" is automatically added so there is no need to add it in your query.
public SearchQuery setEnforceSecurity(boolean enforce)
public SearchQuery removeSecurityToken(java.lang.String token)
public SearchParameter[] getParameters()
getParameters
in class AbstractQuery<SearchQuery,SearchParameter>
@Deprecated public SearchQuery setSortField(java.lang.String fieldName)
fieldName
- the name of a field (that can be used for sorting)@Deprecated public SearchQuery setSortField(java.lang.String fieldName, boolean isSecondary)
Warning this method is not supported on the 4.6 product
fieldName
- the name of a field (that can be used for sorting)isSecondary
- wether the sort is secondary or not.
When the sort is secondary it is only applied to the results with the same score.@Deprecated public java.lang.String getSortField()
Note that when using setSortField(String, boolean)
the syntax of the returned
string is the following one:
"sortedFiled::" or "sortedFiled::sec" if the sort is secondary
@Deprecated public void setAscendingSort(boolean isAscending)
@Deprecated public boolean isSortAscending()
@Deprecated public SearchQuery addMetaFromField(java.lang.String metaName, java.lang.String indexField, boolean highlighting, java.lang.Integer maxLength)
metaName
- (mandatory)indexField
- (mandatory)highlighting
- sets the meta should be highlighted or notmaxLength
- sets the maximum length of the meta, optional, if missing default value will be used@Deprecated public SearchQuery addSummaryMetaFromField(java.lang.String metaName, java.lang.String indexField, boolean highlighting, java.lang.Integer maxLength)
Warning, this feature is not supported by CloudView 4.6
metaName
- (mandatory)indexField
- (mandatory)highlighting
- sets the meta should be highlighted or notmaxLength
- sets the maximum length of the meta, optional, if missing default value will be used@Deprecated protected SearchQuery addMetaFromField(java.lang.String metaName, java.lang.String indexField, boolean highlighting, boolean summary, java.lang.Integer maxLength)
@Deprecated public void addMetasFromCSVField(java.lang.String[] metaNames, java.lang.String indexField, java.lang.String[] originalNames, boolean highlighting, java.lang.Integer maxLength)
Warning, this feature is not supported by CloudView 4.6
metaNames
- a list of meta name (mandatory)indexField
- (mandatory) index field name from which the metas should be retrievedoriginalNames
- list of original names, if null metaNames list will be usedhighlighting
- sets the meta should be highlighted or notmaxLength
- sets the maximum length of the meta, optional, if missing default value will be used@Deprecated public SearchQuery removeMeta(java.lang.String metaName)
metaName
- name of the meta to remove@Deprecated public void addCategoryGroup(java.lang.String name, java.lang.String root, java.lang.String directory, boolean inHits, java.lang.Integer maxCategories, java.lang.Integer maxCategoryTreeDepth, java.lang.Integer maxCategoriesPerLevel, java.lang.String sortFunction)
Warning, this feature is not supported by CloudView 4.6
name
- category group nameroot
- root path of the category group, ex: "Top/Source"directory
- name of category field (optional)inHits
- configures whether the categories should be retrieved or notmaxCategories
- maximum number of categories in the group (optional)maxCategoryTreeDepth
- maximum (optional)maxCategoriesPerLevel
- (optional)sortFunction
- supported values are: "count", "relevancy", "alphanum", "num", "date" (optional)@Deprecated public SearchQuery removeCategoryGroup(java.lang.String name)
addCategoryGroup(String, String, String, boolean, Integer, Integer, Integer, String)
Warning, this feature is not supported by CloudView 4.6
name
- the name of the category group the remove for this querypublic void addVirtualField(java.lang.String name, java.lang.String expression)
Warning, this feature is not supported by CloudView 4.6
name
- virtual field nameexpression
- expressionpublic void removeVirtualField(java.lang.String name)
name
- of the virtual field definition to remove@Deprecated public void setStaticRankingExpression(java.lang.String expression)
Warning, this feature is not supported by CloudView 4.6
expression
- static ranking expression@Deprecated public void unSetStaticRankingExpression()
@Deprecated public SearchQuery setTimeout(java.lang.Integer millis)
millis
- query timeout in milliseconds@Deprecated public java.lang.Integer getTimeout()
Warning, this feature is not supported by CloudView 4.6
@Deprecated public SearchQuery setCollapsing(boolean lsb, boolean msb)
Warning, this feature is not supported by CloudView 4.6
lsb
- use the first 32 bits of the fieldmsb
- use the bits from 33 to 64 of the field@Deprecated public java.lang.String getCollapsing()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
Copyright © 2021 Dassault Systèmes, All Rights Reserved.