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

Fixes #321: fix highlight max_analyzer_offset field name to match OS 2.2.0 #322

Merged
merged 4 commits into from
Aug 20, 2023
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Moved `OpenSearch.Client` request classes into their respective namespaces to match those in `OpenSearch.Net` ([#200](https://github.com/opensearch-project/opensearch-net/pull/200), [#202](https://github.com/opensearch-project/opensearch-net/pull/202), [#203](https://github.com/opensearch-project/opensearch-net/pull/203), [#205](https://github.com/opensearch-project/opensearch-net/pull/205), [#206](https://github.com/opensearch-project/opensearch-net/pull/206), [#207](https://github.com/opensearch-project/opensearch-net/pull/207), [#208](https://github.com/opensearch-project/opensearch-net/pull/208), [#209](https://github.com/opensearch-project/opensearch-net/pull/209))
- Removed support for the `net461` target ([#256](https://github.com/opensearch-project/opensearch-net/pull/256))

### Fixed
- Fix highlight max_analyzer_offset field name to match with the one introduced in OpenSearch 2.2.0 ([#322](https://github.com/opensearch-project/opensearch-net/pull/322))

### Dependencies
- Bumps `Microsoft.CodeAnalysis.CSharp` from 4.2.0 to 4.6.0
- Bumps `Microsoft.TestPlatform.ObjectModel` from 17.5.0 to 17.6.3
Expand Down Expand Up @@ -88,4 +91,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

[Unreleased]: https://github.com/opensearch-project/opensearch-net/compare/v1.4.0...main
[1.4.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0
[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0
13 changes: 7 additions & 6 deletions src/OpenSearch.Client/Search/Search/Highlighting/Highlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public interface IHighlight
/// If this setting is set to a non-negative value, the highlighting stops at this defined maximum limit, and the
/// rest of the text is not processed, thus not highlighted and no error is returned.
/// </summary>
[DataMember(Name ="max_analyzed_offset")]
int? MaxAnalyzedOffset { get; set; }
/// <remarks>Introduced in OpenSearch 2.2</remarks>
[DataMember(Name ="max_analyzer_offset")]
int? MaxAnalyzerOffset { get; set; }

[DataMember(Name ="max_fragment_length")]
int? MaxFragmentLength { get; set; }
Expand Down Expand Up @@ -210,7 +211,7 @@ public class Highlight : IHighlight
public QueryContainer HighlightQuery { get; set; }

/// <inheritdoc/>
public int? MaxAnalyzedOffset { get; set; }
public int? MaxAnalyzerOffset { get; set; }

/// <inheritdoc/>
public int? MaxFragmentLength { get; set; }
Expand Down Expand Up @@ -258,7 +259,7 @@ public class HighlightDescriptor<T> : DescriptorBase<HighlightDescriptor<T>, IHi
int? IHighlight.FragmentOffset { get; set; }
int? IHighlight.FragmentSize { get; set; }
QueryContainer IHighlight.HighlightQuery { get; set; }
int? IHighlight.MaxAnalyzedOffset { get; set; }
int? IHighlight.MaxAnalyzerOffset { get; set; }
int? IHighlight.MaxFragmentLength { get; set; }
int? IHighlight.NoMatchSize { get; set; }
int? IHighlight.NumberOfFragments { get; set; }
Expand Down Expand Up @@ -323,8 +324,8 @@ public HighlightDescriptor<T> HighlightQuery(Func<QueryContainerDescriptor<T>, Q
/// <inheritdoc cref="IHighlight.BoundaryMaxScan" />
public HighlightDescriptor<T> BoundaryMaxScan(int? boundaryMaxScan) => Assign(boundaryMaxScan, (a, v) => a.BoundaryMaxScan = v);

/// <inheritdoc cref="IHighlight.MaxAnalyzedOffset" />
public HighlightDescriptor<T> MaxAnalyzedOffset(int? maxAnalyzedOffset) => Assign(maxAnalyzedOffset, (a, v) => a.MaxAnalyzedOffset = v);
/// <inheritdoc cref="IHighlight.MaxAnalyzerOffset" />
public HighlightDescriptor<T> MaxAnalyzerOffset(int? maxAnalyzerOffset) => Assign(maxAnalyzerOffset, (a, v) => a.MaxAnalyzerOffset = v);

/// <inheritdoc cref="IHighlight.MaxFragmentLength" />
public HighlightDescriptor<T> MaxFragmentLength(int? maxFragmentLength) => Assign(maxFragmentLength, (a, v) => a.MaxFragmentLength = v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ public interface IHighlightField
[DataMember(Name = "matched_fields")]
Fields MatchedFields { get; set; }


/// <summary>
/// If this setting is set to a non-negative value, the highlighting stops at this defined maximum limit, and the
/// rest of the text is not processed, thus not highlighted and no error is returned.
/// </summary>
/// <remarks>Introduced in OpenSearch 2.2</remarks>
[DataMember(Name = "max_analyzer_offset")]
int? MaxAnalyzerOffset { get; set; }

[DataMember(Name = "max_fragment_length")]
int? MaxFragmentLength { get; set; }

Expand Down Expand Up @@ -191,6 +200,7 @@ public interface IHighlightField
/// </summary>
[DataMember(Name = "type")]
Union<HighlighterType, string> Type { get; set; }

}

public class HighlightField : IHighlightField
Expand Down Expand Up @@ -228,6 +238,9 @@ public class HighlightField : IHighlightField
/// <inheritdoc />
public Fields MatchedFields { get; set; }

/// <inheritdoc/>
public int? MaxAnalyzerOffset { get; set; }

/// <inheritdoc />
public int? MaxFragmentLength { get; set; }

Expand Down Expand Up @@ -273,6 +286,9 @@ public class HighlightFieldDescriptor<T> : DescriptorBase<HighlightFieldDescript
int? IHighlightField.FragmentSize { get; set; }
QueryContainer IHighlightField.HighlightQuery { get; set; }
Fields IHighlightField.MatchedFields { get; set; }

int? IHighlightField.MaxAnalyzerOffset { get; set; }

int? IHighlightField.MaxFragmentLength { get; set; }
int? IHighlightField.NoMatchSize { get; set; }
int? IHighlightField.NumberOfFragments { get; set; }
Expand Down Expand Up @@ -349,6 +365,9 @@ public HighlightFieldDescriptor<T> MatchedFields(Func<FieldsDescriptor<T>, IProm
public HighlightFieldDescriptor<T> HighlightQuery(Func<QueryContainerDescriptor<T>, QueryContainer> querySelector) =>
Assign(querySelector, (a, v) => a.HighlightQuery = v?.Invoke(new QueryContainerDescriptor<T>()));

/// <inheritdoc />
public HighlightFieldDescriptor<T> MaxAnalyzerOffset(int? maxAnalyzerOffset) => Assign(maxAnalyzerOffset, (a, v) => a.MaxAnalyzerOffset = v);

/// <inheritdoc />
public HighlightFieldDescriptor<T> MaxFragmentLength(int? maxFragmentLength) => Assign(maxFragmentLength, (a, v) => a.MaxFragmentLength = v);

Expand Down
Loading
Loading