SearcherClient

Updated at:

Sends query requests to OpenSearch. SearcherClient is thread-safe and can be shared across threads.

Constructor

SearcherClient(ServiceClient serviceclient)

Pass a ServiceClient instance to initialize SearcherClient.

ParameterTypeDescription
serviceclientServiceClientThe client that handles communication with OpenSearch.

Thread safety

ObjectThread-safeNotes
SearcherClientYesShare a single instance across threads.

Methods

execute(SearchParams)

SearchResult execute(SearchParams searchParams)

Runs a query defined by a SearchParams object and returns the results in a SearchResult object.

ParameterTypeDescription
searchParamsSearchParamsThe query to run.

Use this method when you have a fully constructed SearchParams object to pass directly.

execute(SearchParamsBuilder)

SearchResult execute(SearchParamsBuilder paramsBuilder)

Runs a query defined by a SearchParamsBuilder object and returns the results in a SearchResult object.

ParameterTypeDescription
paramsBuilderSearchParamsBuilderThe builder that constructs and defines the query to run.

Use this method to construct query parameters fluently using the builder pattern.

executeDebug(SearchParams)

SearchResultDebug executeDebug(SearchParams searchParams)

Runs a query defined by a SearchParams object and returns a SearchResultDebug object. Unlike execute, SearchResultDebug also exposes the raw request string of the last query or push, which is useful for inspecting how the request was constructed.

ParameterTypeDescription
searchParamsSearchParamsThe query to run.

Use executeDebug instead of execute when you need to inspect or log the exact request string sent to OpenSearch — for example, when troubleshooting unexpected query results.