Skip to content

Commit

Permalink
Add support for search ext parameter (#738)
Browse files Browse the repository at this point in the history
* Add support for search `ext` parameter

Signed-off-by: Thomas Farr <[email protected]>

* Fix test

Signed-off-by: Thomas Farr <[email protected]>

---------

Signed-off-by: Thomas Farr <[email protected]>
(cherry picked from commit 12f6dfd)
  • Loading branch information
Xtansia authored and github-actions[bot] committed Aug 5, 2024
1 parent 00b6aaa commit b7433ed
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 582 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Added support for `MinScore` on `ScriptScoreQuery` ([#624](https://github.com/opensearch-project/opensearch-net/pull/624))
- 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))

### Dependencies
- Bumps `AWSSDK.Core` from 3.7.204.12 to 3.7.400.2
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

0 comments on commit b7433ed

Please sign in to comment.