Class SearchRequest
Request for Search
https://opensearch.org/docs/latest/opensearch/rest-api/search/
Inheritance
Inherited Members
Namespace: OpenSearch.Client
Assembly: OpenSearch.Client.dll
Syntax
[DataContract]
public class SearchRequest : PlainRequestBase<SearchRequestParameters>, ISearchRequest, IRequest<SearchRequestParameters>, IRequest, ITypedSearchRequest
Constructors
| Edit this page View SourceSearchRequest()
/_search
Declaration
public SearchRequest()
SearchRequest(Indices)
/{index}/_search
Declaration
public SearchRequest(Indices index)
Parameters
Type | Name | Description |
---|---|---|
Indices | index | Optional, accepts null |
Properties
| Edit this page View SourceAggregations
Specifies the aggregations to perform
Declaration
public AggregationDictionary Aggregations { get; set; }
Property Value
Type | Description |
---|---|
AggregationDictionary |
AllowNoIndices
Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all
string or when no indices have
been specified)
Declaration
public bool? AllowNoIndices { get; set; }
Property Value
Type | Description |
---|---|
bool? |
AllowPartialSearchResults
Indicate if an error should be returned if there is a partial search failure or timeout
Declaration
public bool? AllowPartialSearchResults { get; set; }
Property Value
Type | Description |
---|---|
bool? |
AnalyzeWildcard
Specify whether wildcard and prefix queries should be analyzed (default: false)
Declaration
public bool? AnalyzeWildcard { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Analyzer
The analyzer to use for the query string
Declaration
public string Analyzer { get; set; }
Property Value
Type | Description |
---|---|
string |
BatchedReduceSize
The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
Declaration
public long? BatchedReduceSize { get; set; }
Property Value
Type | Description |
---|---|
long? |
CcsMinimizeRoundtrips
Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
Declaration
public bool? CcsMinimizeRoundtrips { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Collapse
Allows to collapse search results based on field values. The collapsing is done by selecting only the top sorted document per collapse key. For instance the query below retrieves the best tweet for each user and sorts them by number of likes.
NOTE: The collapsing is applied to the top hits only and does not affect aggregations. You can only collapse to a depth of 2.
Declaration
public IFieldCollapse Collapse { get; set; }
Property Value
Type | Description |
---|---|
IFieldCollapse |
DefaultOperator
The default operator for query string query (AND or OR)
Declaration
public DefaultOperator? DefaultOperator { get; set; }
Property Value
Type | Description |
---|---|
DefaultOperator? |
Df
The field to use as default where no field prefix is given in the query string
Declaration
public string Df { get; set; }
Property Value
Type | Description |
---|---|
string |
DocValueFields
Declaration
public Fields DocValueFields { get; set; }
Property Value
Type | Description |
---|---|
Fields |
ExpandWildcards
Whether to expand wildcard expression to concrete indices that are open, closed or both.
Declaration
public ExpandWildcards? ExpandWildcards { get; set; }
Property Value
Type | Description |
---|---|
ExpandWildcards? |
Explain
Enables explanation for each hit on how its score was computed
Declaration
public bool? Explain { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Fields
BETA: Allows for retrieving a list of document fields in the search response.
This functionality is in beta and is subject to change.
Declaration
public Fields Fields { get; set; }
Property Value
Type | Description |
---|---|
Fields |
From
The starting from index of the hits to return. Defaults to 0.
Declaration
public int? From { get; set; }
Property Value
Type | Description |
---|---|
int? |
Highlight
Allow to highlight search results on one or more fields. The implementation uses the either lucene fast-vector-highlighter or highlighter.
Declaration
public IHighlight Highlight { get; set; }
Property Value
Type | Description |
---|---|
IHighlight |
HttpMethod
Declaration
protected override HttpMethod HttpMethod { get; }
Property Value
Type | Description |
---|---|
HttpMethod |
Overrides
| Edit this page View SourceIgnoreThrottled
Whether specified concrete, expanded or aliased indices should be ignored when throttled
Declaration
public bool? IgnoreThrottled { get; set; }
Property Value
Type | Description |
---|---|
bool? |
IgnoreUnavailable
Whether specified concrete indices should be ignored when unavailable (missing or closed)
Declaration
public bool? IgnoreUnavailable { get; set; }
Property Value
Type | Description |
---|---|
bool? |
IndicesBoost
Allows to configure different boost level per index when searching across more than one indices. This is very handy when hits coming from one index matter more than hits coming from another index (think social graph where each user has an index).
Declaration
public IDictionary<IndexName, double> IndicesBoost { get; set; }
Property Value
Type | Description |
---|---|
IDictionary<IndexName, double> |
Lenient
Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
Declaration
public bool? Lenient { get; set; }
Property Value
Type | Description |
---|---|
bool? |
MaxConcurrentShardRequests
The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
Declaration
public long? MaxConcurrentShardRequests { get; set; }
Property Value
Type | Description |
---|---|
long? |
MinScore
Allows to filter out documents based on a minimum score
Declaration
public double? MinScore { get; set; }
Property Value
Type | Description |
---|---|
double? |
PointInTime
Search against a dataset frozen at a point-in-time (PIT)
https://opensearch.org/docs/latest/search-plugins/point-in-time/Declaration
public IPointInTime PointInTime { get; set; }
Property Value
Type | Description |
---|---|
IPointInTime |
Remarks
Supported by OpenSearch servers of version 2.4.0 or greater.
See Also
| Edit this page View SourcePostFilter
Specify a query to apply to the search hits at the very end of a search request, after aggregations have already been calculated. Useful when both search hits and aggregations will be returned in the response, and a filter should only be applied to the search hits.
Declaration
public QueryContainer PostFilter { get; set; }
Property Value
Type | Description |
---|---|
QueryContainer |
PreFilterShardSize
A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
Declaration
public long? PreFilterShardSize { get; set; }
Property Value
Type | Description |
---|---|
long? |
Preference
Specify the node or shard the operation should be performed on (default: random)
Declaration
public string Preference { get; set; }
Property Value
Type | Description |
---|---|
string |
Profile
The Profile API provides detailed timing information about the execution of individual components in a query. It gives the user insight into how queries are executed at a low level so that the user can understand why certain queries are slow, and take steps to improve their slow queries.
Declaration
public bool? Profile { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Query
Specify the search query to perform
Declaration
public QueryContainer Query { get; set; }
Property Value
Type | Description |
---|---|
QueryContainer |
QueryOnQueryString
Query in the Lucene query string syntax
Declaration
public string QueryOnQueryString { get; set; }
Property Value
Type | Description |
---|---|
string |
RequestCache
Specify if request cache should be used for this request or not, defaults to index level setting
Declaration
public bool? RequestCache { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Rescore
Specify one or more queries to use for rescoring
Declaration
public IList<IRescore> Rescore { get; set; }
Property Value
Type | Description |
---|---|
IList<IRescore> |
Routing
A document is routed to a particular shard in an index using the following formula
shard_num = hash(_routing) % num_primary_shards
OpenSearch will use the document id if not provided.
For requests that are constructed from/for a document OSC will automatically infer the routing key if that document has a JoinField or a routing mapping on for its type exists on ConnectionSettings
Declaration
public Routing Routing { get; set; }
Property Value
Type | Description |
---|---|
Routing |
RuntimeFields
Specifies runtime fields which exist only as part of the query.
Declaration
public IRuntimeFields RuntimeFields { get; set; }
Property Value
Type | Description |
---|---|
IRuntimeFields |
ScriptFields
Allows to return a script evaluation (based on different fields) for each hit
Declaration
public IScriptFields ScriptFields { get; set; }
Property Value
Type | Description |
---|---|
IScriptFields |
Scroll
Specify how long a consistent view of the index should be maintained for scrolled search
Declaration
public Time Scroll { get; set; }
Property Value
Type | Description |
---|---|
Time |
SearchAfter
Sort values that can be used to start returning results "after" any document in the result list.
Declaration
public IList<object> SearchAfter { get; set; }
Property Value
Type | Description |
---|---|
IList<object> |
SearchType
Search operation type
Declaration
public SearchType? SearchType { get; set; }
Property Value
Type | Description |
---|---|
SearchType? |
Self
Declaration
protected ISearchRequest Self { get; }
Property Value
Type | Description |
---|---|
ISearchRequest |
SequenceNumberPrimaryTerm
Specify whether to return sequence number and primary term of the last modification of each hit
Declaration
public bool? SequenceNumberPrimaryTerm { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Size
The number of hits to return. Defaults to 10.
Declaration
public int? Size { get; set; }
Property Value
Type | Description |
---|---|
int? |
Slice
For scroll queries that return a lot of documents it is possible to split the scroll in multiple slices which can be consumed independently
Declaration
public ISlicedScroll Slice { get; set; }
Property Value
Type | Description |
---|---|
ISlicedScroll |
Sort
Specifies how to sort the search hits
Declaration
public IList<ISort> Sort { get; set; }
Property Value
Type | Description |
---|---|
IList<ISort> |
Source
Specify how the _source field is returned for each search hit.
When true
, _source retrieval is enabled (default)
When false
, _source retrieval is disabled, and no _source will be returned for each hit
When ISourceFilter is specified, fields to include/exclude can be controlled
Declaration
public Union<bool, ISourceFilter> Source { get; set; }
Property Value
Type | Description |
---|---|
Union<bool, ISourceFilter> |
Stats
Specific 'tag' of the request for logging and statistical purposes
Declaration
public string[] Stats { get; set; }
Property Value
Type | Description |
---|---|
string[] |
StoredFields
Declaration
public Fields StoredFields { get; set; }
Property Value
Type | Description |
---|---|
Fields |
Suggest
The suggest feature suggests similar looking terms based on a provided text by using a suggester
Declaration
public ISuggestContainer Suggest { get; set; }
Property Value
Type | Description |
---|---|
ISuggestContainer |
SuggestField
Specify which field to use for suggestions
Declaration
public Field SuggestField { get; set; }
Property Value
Type | Description |
---|---|
Field |
SuggestMode
Specify suggest mode
Declaration
public SuggestMode? SuggestMode { get; set; }
Property Value
Type | Description |
---|---|
SuggestMode? |
SuggestSize
How many suggestions to return in response
Declaration
public long? SuggestSize { get; set; }
Property Value
Type | Description |
---|---|
long? |
SuggestText
The source text for which the suggestions should be returned
Declaration
public string SuggestText { get; set; }
Property Value
Type | Description |
---|---|
string |
TerminateAfter
The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. If set, the response will have a boolean field terminated_early to indicate whether the query execution has actually terminated_early.
Declaration
public long? TerminateAfter { get; set; }
Property Value
Type | Description |
---|---|
long? |
Timeout
A search timeout, bounding the search request to be executed within the specified time value and bail with the hits accumulated up to that point, when expired. Defaults to no timeout.
Declaration
public string Timeout { get; set; }
Property Value
Type | Description |
---|---|
string |
TotalHitsAsInteger
Indicates whether hits.total should be rendered as an integer or an object in the rest search response
Declaration
public bool? TotalHitsAsInteger { get; set; }
Property Value
Type | Description |
---|---|
bool? |
TrackScores
Make sure we keep calculating score even if we are sorting on a field.
Declaration
public bool? TrackScores { get; set; }
Property Value
Type | Description |
---|---|
bool? |
TrackTotalHits
Declaration
public TrackTotalHits TrackTotalHits { get; set; }
Property Value
Type | Description |
---|---|
TrackTotalHits |
TypedKeys
Specify whether aggregation and suggester names should be prefixed by their respective types in the response
Declaration
public bool? TypedKeys { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Version
Return a version for each search hit
Declaration
public bool? Version { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Methods
| Edit this page View SourceRequestDefaults(SearchRequestParameters)
Allows a request implementation to set certain request parameter defaults, use sparingly!
Declaration
protected override sealed void RequestDefaults(SearchRequestParameters parameters)
Parameters
Type | Name | Description |
---|---|---|
SearchRequestParameters | parameters |
Overrides
| Edit this page View SourceResolveUrl(RouteValues, IConnectionSettingsValues)
Declaration
protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings)
Parameters
Type | Name | Description |
---|---|---|
RouteValues | routeValues | |
IConnectionSettingsValues | settings |
Returns
Type | Description |
---|---|
string |