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]>
  • Loading branch information
Xtansia authored Aug 5, 2024
1 parent c63fbfd commit 12f6dfd
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 @@ -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

0 comments on commit 12f6dfd

Please sign in to comment.