@@ -23,6 +23,8 @@ public class HighlightingUsageTests : SearchUsageTestBase
2323 {
2424 public HighlightingUsageTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
2525
26+ public string LastNameSearch { get ; } = Project . Projects . First ( ) . LeadDeveloper . LastName ;
27+
2628 protected override object ExpectJson => new
2729 {
2830 query = new
@@ -72,6 +74,26 @@ public HighlightingUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : ba
7274 }
7375 }
7476 } ,
77+ { "leadDeveloper.lastName" , new JObject
78+ {
79+ { "type" , "unified" } ,
80+ { "pre_tags" , new JArray { "<name>" } } ,
81+ { "post_tags" , new JArray { "</name>" } } ,
82+ { "highlight_query" , new JObject
83+ {
84+ { "match" , new JObject
85+ {
86+ { "leadDeveloper.lastName" , new JObject
87+ {
88+ { "query" , LastNameSearch }
89+ }
90+ }
91+ }
92+ }
93+ }
94+ }
95+ }
96+ } ,
7597 { "state.offsets" , new JObject
7698 {
7799 { "type" , "postings" } ,
@@ -122,6 +144,17 @@ public HighlightingUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : ba
122144 . Query ( "Kurt Edgardo Naomi Dariana Justice Felton" )
123145 )
124146 ) ,
147+ fs => fs
148+ . Field ( p => p . LeadDeveloper . LastName )
149+ . Type ( HighlighterType . Unified )
150+ . PreTags ( "<name>" )
151+ . PostTags ( "</name>" )
152+ . HighlightQuery ( q => q
153+ . Match ( m => m
154+ . Field ( p => p . LeadDeveloper . LastName )
155+ . Query ( LastNameSearch )
156+ )
157+ ) ,
125158 fs => fs
126159 . Field ( p => p . State . Suffix ( "offsets" ) )
127160 . Type ( HighlighterType . Postings )
@@ -175,6 +208,18 @@ public HighlightingUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : ba
175208 }
176209 }
177210 } ,
211+ { "leadDeveloper.lastName" , new HighlightField
212+ {
213+ Type = HighlighterType . Unified ,
214+ PreTags = new [ ] { "<name>" } ,
215+ PostTags = new [ ] { "</name>" } ,
216+ HighlightQuery = new MatchQuery
217+ {
218+ Field = "leadDeveloper.lastName" ,
219+ Query = LastNameSearch
220+ }
221+ }
222+ } ,
178223 { "state.offsets" , new HighlightField
179224 {
180225 Type = HighlighterType . Postings ,
@@ -215,6 +260,14 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
215260 highlight . Should ( ) . Contain ( "</name>" ) ;
216261 }
217262 }
263+ else if ( highlightField . Key == "leadDeveloper.lastName " )
264+ {
265+ foreach ( var highlight in highlightField . Value . Highlights )
266+ {
267+ highlight . Should ( ) . Contain ( "<name>" ) ;
268+ highlight . Should ( ) . Contain ( "</name>" ) ;
269+ }
270+ }
218271 else if ( highlightField . Key == "state.offsets" )
219272 {
220273 foreach ( var highlight in highlightField . Value . Highlights )
0 commit comments