Skip to content

Commit a95f597

Browse files
committed
Add enum overload to set the highlighter type
1 parent 6b3a6bb commit a95f597

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/Nest/DSL/Search/HighlightFieldDescriptor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ public HighlightFieldDescriptor<T> Type(string type)
138138
Self.Type = type;
139139
return this;
140140
}
141+
public HighlightFieldDescriptor<T> Type(HighlighterType type)
142+
{
143+
Self.Type = type.GetStringValue();
144+
return this;
145+
}
141146
public HighlightFieldDescriptor<T> PreTags(string preTags)
142147
{
143148
Self.PreTags = new[] { preTags };

src/Nest/Enums/HighlighterType.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.Serialization;
5+
using System.Text;
6+
7+
namespace Nest
8+
{
9+
public enum HighlighterType
10+
{
11+
[EnumMember(Value = "plain")]
12+
Plain,
13+
[EnumMember(Value = "postings")]
14+
Postings,
15+
[EnumMember(Value = "fvh")]
16+
Fvh
17+
}
18+
}

src/Nest/Nest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
<Compile Include="Enums\FieldDataLoading.cs" />
370370
<Compile Include="Enums\FieldDataNonStringFormat.cs" />
371371
<Compile Include="Enums\FieldDataStringFormat.cs" />
372+
<Compile Include="Enums\HighlighterType.cs" />
372373
<Compile Include="Enums\NormsLoading.cs" />
373374
<Compile Include="Enums\RoutingAllocationEnableOption.cs" />
374375
<Compile Include="Enums\ScriptLang.cs" />

src/Tests/Nest.Tests.Unit/Search/Highlight/HighlightTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void TestHighlight()
3535
.NoMatchSize(200)
3636
.PreTags("<em>")
3737
.PostTags("</em>")
38+
.Type(HighlighterType.Plain)
3839
)
3940
);
4041
var json = TestElasticClient.Serialize(s);
@@ -54,7 +55,8 @@ public void TestHighlight()
5455
_all: {
5556
pre_tags: [""<em>""],
5657
post_tags: [""</em>""],
57-
no_match_size: 200
58+
no_match_size: 200,
59+
type: ""plain""
5860
}
5961
},
6062
require_field_match: true,

0 commit comments

Comments
 (0)