SearchParamsBuilder is a utility class for SearchParams that provides a fluent API for configuring search query parameters.
Constructors
SearchParamsBuilder.create(SearchParams otherSearchParams)
Creates a SearchParamsBuilder from an existing SearchParams object.
Signature
static SearchParamsBuilder SearchParamsBuilder.create(SearchParams otherSearchParams)Parameters
| Parameter | Type | Description |
|---|---|---|
otherSearchParams | SearchParams | The SearchParams object to initialize the builder from. |
SearchParamsBuilder.create(Config config)
Creates a SearchParamsBuilder from a Config object.
Signature
static SearchParamsBuilder SearchParamsBuilder.create(Config config)Parameters
| Parameter | Type | Description |
|---|---|---|
config | Config | The Config object to initialize the builder from. |
Methods
addFilter(String filter)
Adds a filter expression to the query.
Signature
SearchParamsBuilder addFilter(String filter)Parameters
| Parameter | Type | Description |
|---|---|---|
filter | String | The filter expression. Example: fieldName >= 1. |
addFilter(String filter, String operator)
Adds a filter expression to the query and specifies how it combines with previously added filters.
Signature
SearchParamsBuilder addFilter(String filter, String operator)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
filter | String | — | The filter expression. Example: fieldName >= 1. |
operator | String | AND | How this filter combines with previously added filters. Valid values: AND, OR. AND requires all conditions to match. OR returns results matching any condition. |
addCustomParam(String key, String value)
Adds a custom key-value parameter to the query.
Signature
SearchParamsBuilder addCustomParam(String key, String value)Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | The parameter key. |
value | String | The parameter value. |
addDisableFunction(String function, String value)
Disables a specific feature.
Signature
SearchParamsBuilder addDisableFunction(String function, String value)Parameters
| Parameter | Type | Description |
|---|---|---|
function | String | The name of the feature to disable. |
value | String | The value associated with the feature. |
addDistinct(String key, int distCount, int distTimes, boolean reserved, String distFilter, boolean updateTotalHit, double grade)
Configures distinct extraction, which deduplicates search results by grouping documents with the same field value and returning only a specified number per group.
Signature
SearchParamsBuilder addDistinct(String key, int distCount, int distTimes, boolean reserved, String distFilter, boolean updateTotalHit, double grade)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
key | String | — | The field to group documents by. Must be an attribute field. |
distCount | int | 1 | The number of documents to return per group per extraction pass. |
distTimes | int | 1 | The number of extraction passes to perform. |
reserved | boolean | true | Specifies whether to keep documents not selected during extraction. If true, remaining documents are included in the result set. If false, they are discarded. |
distFilter | String | All documents | The filter condition that determines which documents are eligible for extraction. Documents excluded by this filter are not extracted but are sorted together with the first group in the results. |
updateTotalHit | boolean | false | Specifies whether to subtract the count of discarded documents from totalHits. Only applies when reserved is false. If true, totalHits is adjusted, but the result may be approximate. |
grade | double | — | The threshold for distinct extraction. |
Usage
updateTotalHitonly takes effect whenreservedisfalse. Whenreservedistrue, no documents are discarded andtotalHitsis unaffected.Documents excluded by
distFilterare not extracted but still appear in the results, sorted together with the first extraction group.
addSummary(String fieldName, Integer len, String element, String ellipsis, Integer snippet)
Configures a dynamic summary for search results. The summary highlights the portions of a text field that match the query.
Signature
SearchParamsBuilder addSummary(String fieldName, Integer len, String element, String ellipsis, Integer snippet)Parameters
| Parameter | Type | Description |
|---|---|---|
fieldName | String | The field to generate summaries from. Must be a text field (analyzed). |
len | Integer | The maximum length of each summary snippet, in bytes. |
element | String | The HTML element used to highlight matched terms. Example: em. |
ellipsis | String | The string inserted where content is omitted. Example: "...". |
snippet | Integer | The maximum number of summary snippets returned per query. |
Field values may be trimmed or highlighted based on the dynamic summary rule.