@@ -79,7 +79,8 @@ public interface IHighlightField
79
79
/// Define how highlighted text will be encoded.
80
80
/// It can be either default (no encoding) or html (will escape html, if you use html highlighting tags).
81
81
/// </summary>
82
- [ JsonProperty ( "encoder" ) ]
82
+ [ JsonIgnore ]
83
+ [ Obsolete ( "Encoder not valid on highlight field. Removed in NEST 6.x" ) ]
83
84
string Encoder { get ; set ; }
84
85
85
86
/// <summary>
@@ -118,14 +119,14 @@ public interface IHighlightField
118
119
/// <summary>
119
120
/// The type of highlighter to use
120
121
/// </summary>
121
- HighlighterType ? Type { get ; set ; }
122
+ [ JsonProperty ( "type" ) ]
123
+ [ Obsolete ( "This is a temporary binary backwards compatible fix to make sure you can specify any custom highlighter type in 2.0.0. Removed in 5.0.0." ) ]
124
+ string CustomType { get ; set ; }
122
125
123
126
/// <summary>
124
127
/// The type of highlighter to use
125
128
/// </summary>
126
- [ JsonProperty ( "type" ) ]
127
- [ Obsolete ( "This is a temporary binary backwards compatible fix to make sure you can specify any custom highlighter type in 2.0.0. Removed in 5.0.0." ) ]
128
- string CustomType { get ; set ; }
129
+ HighlighterType ? Type { get ; set ; }
129
130
130
131
/// <summary>
131
132
/// Forces the highlighting to highlight fields based on the source even if fields are stored separately.
@@ -147,6 +148,15 @@ public interface IHighlightField
147
148
/// </summary>
148
149
[ JsonProperty ( "highlight_query" ) ]
149
150
QueryContainer HighlightQuery { get ; set ; }
151
+
152
+ /// <summary>
153
+ /// Controls the number of matching phrases in a document that are considered. Prevents the
154
+ /// <see cref="HighlighterType.Fvh"/> highlighter from analyzing too many phrases and consuming too much memory.
155
+ /// When using matched_fields, <see cref="PhraseLimit"/> phrases per matched field are considered. Raising the limit increases query time
156
+ /// and consumes more memory. Only supported by the <see cref="HighlighterType.Fvh"/> highlighter. Defaults to 256.
157
+ /// </summary>
158
+ [ JsonProperty ( "phrase_limit" ) ]
159
+ int ? PhraseLimit { get ; set ; }
150
160
}
151
161
152
162
public class HighlightField : IHighlightField
@@ -208,11 +218,8 @@ public class HighlightField : IHighlightField
208
218
209
219
[ Obsolete ( "Use BoundaryMaxScan" ) ]
210
220
public int ? BoundaryMaxSize { get ; set ; }
211
-
212
- /// <summary>
213
- /// Define how highlighted text will be encoded.
214
- /// It can be either default (no encoding) or html (will escape html, if you use html highlighting tags).
215
- /// </summary>
221
+ /// <inheritdoc/>
222
+ [ Obsolete ( "Encoder not valid on highlight field. Removed in NEST 6.x" ) ]
216
223
public string Encoder { get ; set ; }
217
224
218
225
/// <summary>
@@ -244,6 +251,11 @@ public class HighlightField : IHighlightField
244
251
/// </summary>
245
252
public string BoundaryChars { get ; set ; }
246
253
254
+ /// <summary>
255
+ /// The type of highlighter to use.
256
+ /// </summary>
257
+ public string CustomType { get ; set ; }
258
+
247
259
/// <summary>
248
260
/// The type of highlighter to use.
249
261
/// </summary>
@@ -253,11 +265,6 @@ public HighlighterType? Type
253
265
set { this . CustomType = value . GetStringValue ( ) ; }
254
266
}
255
267
256
- /// <summary>
257
- /// The type of highlighter to use.
258
- /// </summary>
259
- public string CustomType { get ; set ; }
260
-
261
268
/// <summary>
262
269
/// Forces the highlighting to highlight fields based on the source even if fields are stored separately.
263
270
/// </summary>
@@ -275,6 +282,9 @@ public HighlighterType? Type
275
282
/// The query to use for highlighting
276
283
/// </summary>
277
284
public QueryContainer HighlightQuery { get ; set ; }
285
+
286
+ /// <inheritdoc/>
287
+ public int ? PhraseLimit { get ; set ; }
278
288
}
279
289
280
290
public class HighlightFieldDescriptor < T > : DescriptorBase < HighlightFieldDescriptor < T > , IHighlightField > , IHighlightField
@@ -289,23 +299,24 @@ public class HighlightFieldDescriptor<T> : DescriptorBase<HighlightFieldDescript
289
299
int ? IHighlightField . FragmentOffset { get ; set ; }
290
300
int ? IHighlightField . BoundaryMaxSize { get ; set ; }
291
301
int ? IHighlightField . BoundaryMaxScan { get ; set ; }
302
+ [ Obsolete ( "Encoder not valid on highlight field. Removed in NEST 6.x" ) ]
292
303
string IHighlightField . Encoder { get ; set ; }
293
304
string IHighlightField . Order { get ; set ; }
294
305
string IHighlightField . TagsSchema { get ; set ; }
295
306
bool ? IHighlightField . RequireFieldMatch { get ; set ; }
296
307
string IHighlightField . BoundaryChars { get ; set ; }
308
+ string IHighlightField . CustomType { get ; set ; }
297
309
HighlighterType ? IHighlightField . Type
298
310
{
299
311
#pragma warning disable CS0618 // Type or member is obsolete
300
312
get { return Self . CustomType . ToEnum < HighlighterType > ( ) ; }
301
313
set { Self . CustomType = value . GetStringValue ( ) ; }
302
314
#pragma warning restore CS0618 // Type or member is obsolete
303
315
}
304
- string IHighlightField . CustomType { get ; set ; }
305
316
bool ? IHighlightField . ForceSource { get ; set ; }
306
317
Fields IHighlightField . MatchedFields { get ; set ; }
307
-
308
318
QueryContainer IHighlightField . HighlightQuery { get ; set ; }
319
+ int ? IHighlightField . PhraseLimit { get ; set ; }
309
320
310
321
/// <summary>
311
322
/// The field on which to perform highlighting.
@@ -358,10 +369,10 @@ public class HighlightFieldDescriptor<T> : DescriptorBase<HighlightFieldDescript
358
369
/// </summary>
359
370
public HighlightFieldDescriptor < T > Type ( HighlighterType type ) => Assign ( a => a . Type = type ) ;
360
371
372
+ #pragma warning disable CS0618 // Type or member is obsolete
361
373
/// <summary>
362
374
/// The type of highlighter to use
363
375
/// </summary>
364
- #pragma warning disable CS0618 // Type or member is obsolete
365
376
public HighlightFieldDescriptor < T > Type ( string type ) => Assign ( a => a . CustomType = type ) ;
366
377
#pragma warning restore CS0618 // Type or member is obsolete
367
378
@@ -373,18 +384,18 @@ public class HighlightFieldDescriptor<T> : DescriptorBase<HighlightFieldDescript
373
384
public HighlightFieldDescriptor < T > PreTags ( string preTags ) => Assign ( a => a . PreTags = new [ ] { preTags } ) ;
374
385
375
386
/// <summary>
376
- /// Controls the pre tag in which to wrap highights.
387
+ /// Controls the post tag in which to wrap highights.
377
388
/// By default, the highlighting will wrap highlighted text in <em> and </em>.
378
389
/// Using the fast vector highlighter, there can be more tags, and the importance is ordered.
379
390
/// </summary>
380
- public HighlightFieldDescriptor < T > PreTags ( IEnumerable < string > preTags ) => Assign ( a => a . PreTags = preTags ) ;
391
+ public HighlightFieldDescriptor < T > PostTags ( IEnumerable < string > postTags ) => Assign ( a => a . PostTags = postTags ) ;
381
392
382
393
/// <summary>
383
- /// Controls the post tag in which to wrap highights.
394
+ /// Controls the pre tag in which to wrap highights.
384
395
/// By default, the highlighting will wrap highlighted text in <em> and </em>.
385
396
/// Using the fast vector highlighter, there can be more tags, and the importance is ordered.
386
397
/// </summary>
387
- public HighlightFieldDescriptor < T > PostTags ( IEnumerable < string > postTags ) => Assign ( a => a . PostTags = postTags ) ;
398
+ public HighlightFieldDescriptor < T > PreTags ( IEnumerable < string > preTags ) => Assign ( a => a . PreTags = preTags ) ;
388
399
389
400
/// <summary>
390
401
/// Controls the post tag in which to wrap highights.
@@ -423,6 +434,7 @@ public class HighlightFieldDescriptor<T> : DescriptorBase<HighlightFieldDescript
423
434
/// Define how highlighted text will be encoded.
424
435
/// It can be either default (no encoding) or html (will escape html, if you use html highlighting tags).
425
436
/// </summary>
437
+ [ Obsolete ( "Encoder not valid on highlight field. Removed in NEST 6.x" ) ]
426
438
public HighlightFieldDescriptor < T > Encoder ( string encoder ) => Assign ( a => a . Encoder = encoder ) ;
427
439
428
440
/// <summary>
@@ -464,5 +476,13 @@ public HighlightFieldDescriptor<T> MatchedFields(Func<FieldsDescriptor<T>, IProm
464
476
/// </summary>
465
477
public HighlightFieldDescriptor < T > HighlightQuery ( Func < QueryContainerDescriptor < T > , QueryContainer > querySelector ) =>
466
478
Assign ( a => a . HighlightQuery = querySelector ? . Invoke ( new QueryContainerDescriptor < T > ( ) ) ) ;
479
+
480
+ /// <summary>
481
+ /// Controls the number of matching phrases in a document that are considered. Prevents the
482
+ /// <see cref="HighlighterType.Fvh"/> highlighter from analyzing too many phrases and consuming too much memory.
483
+ /// When using matched_fields, <see cref="PhraseLimit"/> phrases per matched field are considered. Raising the limit increases query time
484
+ /// and consumes more memory. Only supported by the <see cref="HighlighterType.Fvh"/> highlighter. Defaults to 256.
485
+ /// </summary>
486
+ public HighlightFieldDescriptor < T > PhraseLimit ( int phraseLimit ) => Assign ( a => a . PhraseLimit = phraseLimit ) ;
467
487
}
468
488
}
0 commit comments