All Products
Search
Document Center

OpenSearch:SearchParamsBuilder

Last Updated:Sep 09, 2021

Overview

The SearchParamsBuilder class is used to construct a parameter object for a SearchParams object.

Constructor

Method definition

mixed  OpenSearch\Util\SearchParamsBuilder::__construct($opts)

Parameter description

Parameter

Type

Description

$opts

mixed

The query parameters.


setStart

Specifies the ordinal number of the first document to be returned in search results.

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setStart(integer $start)

Parameter description

Parameter

Type

Description

$start

integer

The ordinal number of the first document to be returned in search results.


setHits

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setHits( $hits)

Parameter description

Parameter

Type

Description

$hits

integer

The maximum number of documents in each result set.


setFormat

Specifies the data format of return results. Supported formats are XML, JSON, and FULLJSON. Compared with the JSON format, the FULLJSON format supports extra fields such as variableValue.

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setFormat(String $format)

Parameter description

Parameter

Type

Description

$format

string

The data format of return results.


setAppName

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setAppName($appNames)

Parameter description

Parameter

Type

Description

$appNames

mixed

The name of the application for which you want to implement the search feature.


setQuery

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setQuery( $query)

Parameter description

Parameter

Type

Description

$query

string

The query keyword in the following format: Index field name:'Keyword' [ AND or OR … ].


setKvPairs

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setKvPairs( $kvPairs)

Parameter description

Parameter

Type

Description

$kvPairs

string

The key-value pairs that you want to set.


setFetchFields

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setFetchFields(array $fetchFields)

Parameter description

Parameter

Type

Description

$fetchFields

array

The fields to be returned in results. Example: array('a', 'b').


setRouteValue

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setRouteValue( $routeValue)

Parameter description

Parameter

Type

Description

$routeValue

mixed

The field values that are used for grouping.


setCustomConfig

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setCustomConfig(String $key, Mixed $value)

Parameter description

Parameter

Type

Description

$key

string

The key of the custom parameter.

$value

mixed

The value of the custom parameter.


addFilter

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addFilter( $filter,  $condition)

Parameter description

Parameter

Type

Description

$filter

string

The filter condition. Example: a>1.

$condition

string

The logical operator to connect the two filter conditions, such as AND and OR.


setFilter

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setFilter($filterString)

Parameter description

Parameter

Type

Description

$filterString

mixed

The filter condition.


addSort

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addSort( $field, $order)

Parameter description

Parameter

Type

Description

$field

string

The field based on which documents are to be sorted.

$order

mixed

The sorting method. Valid values: SearchParamsBuilder::SORT_INCREASE and SearchParamsBuilder::SORT_DECREASE.


setFirstRankName

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setFirstRankName( $firstRankName)

Parameter description

Parameter

Type

Description

$firstRankName

string

The name that you want to set for the rough sort expression.


setSecondRankName

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setSecondRankName( $secondRankName)

Parameter description

Parameter

Type

Description

$secondRankName

string

The name that you want to set for the fine sort expression.


addAggregate

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addAggregate( $agg)

Parameter description

Parameter

Type

Description

$agg

array

The aggregation configurations that you want to specify.


addDistinct

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addDistinct( $dist)

Parameter description

Parameter

Type

Description

$dist

array

The deduplication configurations that you want to specify.


addSummary

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addSummary( $summaryMeta)

Parameter description

Parameter

Type

Description

$summaryMeta

array

The summary field configurations that you want to specify.


addQueryProcessor

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addQueryProcessor( $qpName)

Parameter description

Parameter

Type

Description

$qpName

array

The query analysis configurations that you want to specify.


addDisableFunctions

Method definition

void  OpenSearch\Util\SearchParamsBuilder::addDisableFunctions( $disabledFunction)

Parameter description

Parameter

Type

Description

$disabledFunction

string

The custom parameter to be disabled.


setCustomParam

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setCustomParam( $key,  $value)

Parameter description

Parameter

Type

Description

$key

string

The key of the custom parameter.

$value

string

The value of the custom parameter.


setScrollExpire

Sets a timeout period for each scroll query.

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setScrollExpire($expiredTime)

Parameter description

Parameter

Type

Description

$expiredTime

mixed

The timeout period for each scroll query, in minutes. Example: 3m.


setScrollId

Specifies the ID of the scroll query to be run. The ID is returned after the first scroll query is run.

Method definition

void  OpenSearch\Util\SearchParamsBuilder::setScrollId(String $scrollId)

Parameter description

Parameter

Type

Description

$scrollId

string

The ID of the scroll query to be run.


build

Method definition

\OpenSearch\Generated\Search\SearchParams     OpenSearch\Util\SearchParamsBuilder::build()
  • This method is used to create a SearchParams object.