Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for search ext parameter #738

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added support for `MinScore` on `ScriptScoreQuery` ([#624](https://github.com/opensearch-project/opensearch-net/pull/624))
- Added support for the `Cat.PitSegments` and `Cat.SegmentReplication` APIs ([#527](https://github.com/opensearch-project/opensearch-net/pull/527))
- Added support for serializing the `DateOnly` and `TimeOnly` types ([#734](https://github.com/opensearch-project/opensearch-net/pull/734))
- Added support for the `Ext` parameter on `SearchRequest` ([#738](https://github.com/opensearch-project/opensearch-net/pull/738))

### Removed
- Removed support for the `net461` target ([#256](https://github.com/opensearch-project/opensearch-net/pull/256))
Expand Down
15 changes: 15 additions & 0 deletions src/OpenSearch.Client/Search/Search/SearchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public partial interface ISearchRequest : ITypedSearchRequest
/// </summary>
[DataMember(Name = "runtime_mappings")]
IRuntimeFields RuntimeFields { get; set; }

[DataMember(Name = "ext")]
[JsonFormatter(typeof(VerbatimDictionaryInterfaceKeysFormatter<string, object>))]
IDictionary<string, object> Ext { get; set; }
}

[ReadAs(typeof(SearchRequest<>))]
Expand Down Expand Up @@ -288,6 +292,8 @@ public partial class SearchRequest
public bool? Version { get; set; }
/// <inheritdoc />
public IRuntimeFields RuntimeFields { get; set; }
/// <inheritdoc />
public IDictionary<string, object> Ext { get; set; }

protected override HttpMethod HttpMethod =>
RequestState.RequestParameters?.ContainsQueryString("source") == true
Expand Down Expand Up @@ -347,6 +353,7 @@ public partial class SearchDescriptor<TInferDocument> where TInferDocument : cla
TrackTotalHits ISearchRequest.TrackTotalHits { get; set; }
bool? ISearchRequest.Version { get; set; }
IRuntimeFields ISearchRequest.RuntimeFields { get; set; }
IDictionary<string, object> ISearchRequest.Ext { get; set; }

protected sealed override void RequestDefaults(SearchRequestParameters parameters) => TypedKeys();

Expand Down Expand Up @@ -538,6 +545,14 @@ public SearchDescriptor<TInferDocument> PointInTime(Func<PointInTimeDescriptor,
if (a.PointInTime != null) a.RouteValues.Remove("index");
});

/// <inheritdoc cref="ISearchRequest.Ext"/>
public SearchDescriptor<TInferDocument> Ext(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector) =>
Assign(selector(new FluentDictionary<string, object>()), (a, v) => a.Ext = v);

/// <inheritdoc cref="ISearchRequest.Ext"/>
public SearchDescriptor<TInferDocument> Ext(IDictionary<string, object> dictionary) =>
Assign(dictionary, (a, v) => a.Ext = v);

protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings) => base.ResolveUrl(routeValues, settings);
}
}
Loading
Loading