File tree 6 files changed +78
-24
lines changed
Domain/Analysis/TokenFilter
Core/Indices/Analysis/Analyzers
6 files changed +78
-24
lines changed Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using Newtonsoft . Json ;
3
+
4
+ namespace Nest
5
+ {
6
+ /// <summary>
7
+ /// A token filter of type keep that only keeps tokens with text contained in a predefined set of words.
8
+ /// </summary>
9
+ public class KeepTypesTokenFilter : TokenFilterBase
10
+ {
11
+ public KeepTypesTokenFilter ( )
12
+ : base ( "keep_types" )
13
+ {
14
+
15
+ }
16
+
17
+ /// <summary>
18
+ /// A list of types to keep.
19
+ /// </summary>
20
+ [ JsonProperty ( "types" ) ]
21
+ public IEnumerable < string > Types { get ; set ; }
22
+
23
+ }
24
+ }
Original file line number Diff line number Diff line change 3
3
4
4
namespace Nest
5
5
{
6
- /// <summary>
7
- /// A token filter of type keep that only keeps tokens with text contained in a predefined set of words.
8
- /// </summary>
9
- public class KeepWordsTokenFilter : TokenFilterBase
10
- {
11
- public KeepWordsTokenFilter ( )
12
- : base ( "keep" )
13
- {
6
+ /// <summary>
7
+ /// A token filter of type keep that only keeps tokens with text contained in a predefined set of words.
8
+ /// </summary>
9
+ public class KeepWordsTokenFilter : TokenFilterBase
10
+ {
11
+ public KeepWordsTokenFilter ( )
12
+ : base ( "keep" )
13
+ {
14
14
15
- }
15
+ }
16
16
17
- /// <summary>
18
- /// A list of words to keep.
19
- /// </summary>
20
- [ JsonProperty ( "keep_words" ) ]
21
- public IEnumerable < string > KeepWords { get ; set ; }
17
+ /// <summary>
18
+ /// A list of words to keep.
19
+ /// </summary>
20
+ [ JsonProperty ( "keep_words" ) ]
21
+ public IEnumerable < string > KeepWords { get ; set ; }
22
22
23
- /// <summary>
24
- /// A path to a words file.
25
- /// </summary>
26
- [ JsonProperty ( "rules_path" ) ]
27
- public string KeepWordsPath { get ; set ; }
23
+ /// <summary>
24
+ /// A path to a words file.
25
+ /// </summary>
26
+ [ JsonProperty ( "rules_path" ) ]
27
+ public string KeepWordsPath { get ; set ; }
28
28
29
- /// <summary>
30
- /// A boolean indicating whether to lower case the words.
31
- /// </summary>
32
- [ JsonProperty ( "keep_words_case" ) ]
29
+ /// <summary>
30
+ /// A boolean indicating whether to lower case the words.
31
+ /// </summary>
32
+ [ JsonProperty ( "keep_words_case" ) ]
33
33
public bool ? KeepWordsCase { get ; set ; }
34
34
35
- }
35
+ }
36
36
}
Original file line number Diff line number Diff line change 134
134
<Compile Include =" Domain\Analysis\CharFilter\PatternReplaceCharFilter.cs" />
135
135
<Compile Include =" Domain\Analysis\TokenFilter\DelimitedPayloadTokenFilter.cs" />
136
136
<Compile Include =" Domain\Analysis\TokenFilter\CommonGramsTokenFilter.cs" />
137
+ <Compile Include =" Domain\Analysis\TokenFilter\KeepTypesTokenFilter.cs" />
137
138
<Compile Include =" Domain\Analysis\TokenFilter\KeywordRepeatTokenFilter.cs" />
138
139
<Compile Include =" Domain\Analysis\TokenFilter\HunspellTokenFilter.cs" />
139
140
<Compile Include =" Domain\Analysis\TokenFilter\LimitTokenCountTokenFilter.cs" />
Original file line number Diff line number Diff line change @@ -116,5 +116,17 @@ public void WhitespaceAnalyzerTest()
116
116
117
117
this . JsonEquals ( result . ConnectionStatus . Request , MethodInfo . GetCurrentMethod ( ) ) ;
118
118
}
119
+
120
+ [ Test ]
121
+ public void KeepTypesTokenFilter ( )
122
+ {
123
+ var result = this . Analysis ( a => a
124
+ . TokenFilters ( tf => tf
125
+ . Add ( "keep" , new KeepTypesTokenFilter { Types = new [ ] { "<NUM>" } } )
126
+ )
127
+ ) ;
128
+
129
+ this . JsonEquals ( result . ConnectionStatus . Request , MethodInfo . GetCurrentMethod ( ) ) ;
130
+ }
119
131
}
120
132
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "settings" : {
3
+ "index" : {
4
+ "analysis" : {
5
+ "filter" : {
6
+ "keep" : {
7
+ "types" : [ " <NUM>" ],
8
+ "type" : " keep_types"
9
+ }
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change 148
148
<None Include =" Core\Indices\Analysis\Analyzers\LanguageAnalyzerTest.json" >
149
149
<CopyToOutputDirectory >Always</CopyToOutputDirectory >
150
150
</None >
151
+ <None Include =" Core\Indices\Analysis\Analyzers\KeepTypesTokenFilter.json" >
152
+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
153
+ </None >
151
154
<None Include =" Core\Indices\Analysis\Analyzers\WhitespaceAnalyzerTest.json" >
152
155
<CopyToOutputDirectory >Always</CopyToOutputDirectory >
153
156
</None >
You can’t perform that action at this time.
0 commit comments