Overview
As the utility class of SearchParams, the SearchParamsBuilder class allows you to configure query-related parameters with ease.
Constructor (1)
Creates a SearchParamsBuilder object by calling the static method SearchParamsBuilder.create() with a SearchParams object as the parameter.
SearchParamsBuilder SearchParamsBuilder.create(SearchParams otherSearchParams)
Parameter description
Parameter | Type | Description |
---|---|---|
otherSearchParams | SearchParams | The SearchParams object based on which the SearchParamsBuilder object is to be created. |
Constructor (2)
Creates a SearchParamsBuilder object by calling the static method SearchParamsBuilder.create() with a Config object as the parameter.
SearchParamsBuilder SearchParamsBuilder.create(Config config)
Parameter description
Parameter | Type | Description |
---|---|---|
config | Config | The Config object based on which the SearchParamsBuilder object is to be created. |
addFilter (1)
Method definition
Specifies a filter rule.
SearchParamsBuilder addFilter(String filter)
Parameter description
Parameter | Type | Description |
---|---|---|
filter | String | The filter rule. Example: fieldName >= 1. |
addFilter (2)
Method definition
Specifies a filter rule.
SearchParamsBuilder addFilter(String filter,String operator)
Parameter description
Parameter | Type | Description |
---|---|---|
filter | String | The filter rule. Example: fieldName >= 1. |
operator | String | The operator. Valid values: AND and OR. Default value: AND. |
addCustomParam
Method definition
Adds a custom parameter in the form of a key-value pair.
SearchParamsBuilder addCustomParam(String key,String value)
Parameter description
Parameter | Type | Description |
---|---|---|
key | String | The key of the custom parameter. |
value | String | The value of the custom parameter. |
addDisableFunction
Method definition
Disables a feature.
SearchParamsBuilder addDisableFunction(String function,String value)
Parameter description
Parameter | Type | Description |
---|---|---|
function | String | The name of the feature. |
value | String | The value of the parameter that indicates the feature. |
addDistinct
Method definition
Creates a Distinct object for the current SearchParamsBuilder object.
SearchParamsBuilder addDistinct(String key,int distCount,int distTimes,boolean reserved,String distFilter,boolean updateTotalHit,double grade)
Parameter description
Parameter | Type | Description |
---|---|---|
key | String | The field to be used for distinct extraction. This field must be an attribute field. |
distCount | int | The number of documents that are extracted each time. Default value: 1. |
distTimes | int | The number of times of extraction. Default value: 1. |
reserved | boolean | Specifies whether to retain the remaining documents after extraction. If this parameter is set to true, the remaining documents are retained. If this parameter is set to false, the remaining documents are discarded and the number of the discarded documents may be subtracted from the value of the totalHits parameter. Default value: true. |
distFilter | String | The filter condition that is used to select documents to be extracted. The documents that are filtered out will not be extracted, but will be sorted together with the first group of documents in the distinct extraction results. By default, all documents are selected for each distinct extraction. |
updateTotalHit | boolean | Specifies whether to subtract the number of discarded documents from the value of the totalHits parameter if the reserved parameter is set to false. If this parameter is set to true, the number of discarded documents will be subtracted from the value of the totalHits parameter but the result may be inaccurate. If this parameter is set to false, the number of discarded documents will not be subtracted from the value of the totalHits parameter. Default value: false. |
grade | double | The threshold for the distinct extraction. |
addSummary
Method definition
Creates a Summary object for the current SearchParamsBuilder object.
SearchParamsBuilder addSummary(String fieldName, Integer len, String element, String ellipsis, Integer snippet)
Parameter description
Parameter | Type | Description |
---|---|---|
fieldName | String | The field based on which a summary is to be generated. This field must be of the text type so that the field can be analyzed. |
len | Integer | The length of each summary snippet in result sets, in bytes. |
element | String | The element to be used to highlight the query that hit one or more summary snippets. Example: em. |
ellipsis | String | The string to be used to represent the data that is not displayed. Example: "..." |
snippet | Integer | The number of summary snippets that each query can hit. |
Values of the field that is specified by the fieldName parameter may be trimmed or highlighted based on the dynamic summary rule.