diff --git a/src/OpenSearch.Client/Search/Search/Highlighting/HighlightField.cs b/src/OpenSearch.Client/Search/Search/Highlighting/HighlightField.cs
index 4e78137ed6..8702926752 100644
--- a/src/OpenSearch.Client/Search/Search/Highlighting/HighlightField.cs
+++ b/src/OpenSearch.Client/Search/Search/Highlighting/HighlightField.cs
@@ -116,6 +116,15 @@ public interface IHighlightField
[DataMember(Name = "matched_fields")]
Fields MatchedFields { get; set; }
+
+ ///
+ /// 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.
+ ///
+ /// Introduced in OpenSearch 2.2
+ [DataMember(Name = "max_analyzer_offset")]
+ int? MaxAnalyzerOffset { get; set; }
+
[DataMember(Name = "max_fragment_length")]
int? MaxFragmentLength { get; set; }
@@ -191,6 +200,7 @@ public interface IHighlightField
///
[DataMember(Name = "type")]
Union Type { get; set; }
+
}
public class HighlightField : IHighlightField
@@ -228,6 +238,9 @@ public class HighlightField : IHighlightField
///
public Fields MatchedFields { get; set; }
+ ///
+ public int? MaxAnalyzerOffset { get; set; }
+
///
public int? MaxFragmentLength { get; set; }
@@ -273,6 +286,9 @@ public class HighlightFieldDescriptor : DescriptorBase MatchedFields(Func, IProm
public HighlightFieldDescriptor HighlightQuery(Func, QueryContainer> querySelector) =>
Assign(querySelector, (a, v) => a.HighlightQuery = v?.Invoke(new QueryContainerDescriptor()));
+ ///
+ public HighlightFieldDescriptor MaxAnalyzerOffset(int? maxAnalyzerOffset) => Assign(maxAnalyzerOffset, (a, v) => a.MaxAnalyzerOffset = v);
+
///
public HighlightFieldDescriptor MaxFragmentLength(int? maxFragmentLength) => Assign(maxFragmentLength, (a, v) => a.MaxFragmentLength = v);
diff --git a/tests/Tests/Search/Request/HighlightingUsageTestsWithMaxAnalyzerOffset.cs b/tests/Tests/Search/Request/HighlightingUsageTestsWithMaxAnalyzerOffset.cs
index d1f87ba6f6..63faf46347 100644
--- a/tests/Tests/Search/Request/HighlightingUsageTestsWithMaxAnalyzerOffset.cs
+++ b/tests/Tests/Search/Request/HighlightingUsageTestsWithMaxAnalyzerOffset.cs
@@ -94,7 +94,8 @@ public HighlightingUsageTestsWithMaxAnalyzerOffset(ReadOnlyCluster cluster, Endp
{ "fragment_size", 150 },
{ "fragmenter", "span" },
{ "number_of_fragments", 3 },
- { "no_match_size", 150 }
+ { "no_match_size", 150 },
+ { "max_analyzer_offset", 500 }
}
},
{
@@ -179,7 +180,8 @@ public HighlightingUsageTestsWithMaxAnalyzerOffset(ReadOnlyCluster cluster, Endp
.FragmentSize(150)
.Fragmenter(HighlighterFragmenter.Span)
.NumberOfFragments(3)
- .NoMatchSize(150),
+ .NoMatchSize(150)
+ .MaxAnalyzerOffset(500),
fs => fs
.Field(p => p.LeadDeveloper.FirstName)
.Type(HighlighterType.Fvh)
@@ -236,7 +238,8 @@ public HighlightingUsageTestsWithMaxAnalyzerOffset(ReadOnlyCluster cluster, Endp
FragmentSize = 150,
Fragmenter = HighlighterFragmenter.Span,
NumberOfFragments = 3,
- NoMatchSize = 150
+ NoMatchSize = 150,
+ MaxAnalyzerOffset = 500
}
},
{