Skip to content

Commit 76c47b1

Browse files
author
Daniel Silva
committed
Add support for predefined language specific stopwords
1 parent 191d7ae commit 76c47b1

File tree

5 files changed

+1588
-1513
lines changed

5 files changed

+1588
-1513
lines changed

src/Nest/Domain/Analysis/TokenFilter/StopTokenFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public StopTokenFilter() : base("stop")
2323
public string StopwordsPath { get; set; }
2424

2525
[JsonProperty("stopwords")]
26-
public IEnumerable<string> Stopwords { get; set; }
26+
public object Stopwords { get; set; }
2727

2828
[JsonProperty("remove_trailing")]
2929
public bool? RemoveTrailing { get; set; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"settings": {
3+
"index": {
4+
"analysis": {
5+
"filter": {
6+
"my_stop": {
7+
"type": "stop",
8+
"stopwords": [ "and", "is", "the" ]
9+
}
10+
}
11+
}
12+
}
13+
}
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"settings": {
3+
"index": {
4+
"analysis": {
5+
"filter": {
6+
"my_stop": {
7+
"type": "stop",
8+
"stopwords": "_english_"
9+
}
10+
}
11+
}
12+
}
13+
}
14+
}
15+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Nest.Tests.Unit.Core.Indices.Analysis.Tokenizers;
2+
using NUnit.Framework;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Nest.Tests.Unit.Core.Indices.Analysis.TokenFilters
11+
{
12+
[TestFixture]
13+
public class TokenFilterTests : BaseAnalysisTests
14+
{
15+
[Test]
16+
public void TestStopTokenFilterWithArray()
17+
{
18+
var result = this.Analysis(a => a
19+
.TokenFilters(t => t
20+
.Add("my_stop", new StopTokenFilter
21+
{
22+
Stopwords = new string[] { "and", "is", "the" }
23+
})
24+
)
25+
);
26+
this.JsonEquals(result.ConnectionStatus.Request, MethodInfo.GetCurrentMethod());
27+
}
28+
29+
[Test]
30+
public void TestStopTokenFilterWithPredefinedLanguageList()
31+
{
32+
var result = this.Analysis(a => a
33+
.TokenFilters(t => t
34+
.Add("my_stop", new StopTokenFilter
35+
{
36+
Stopwords = "_english_"
37+
})
38+
)
39+
);
40+
this.JsonEquals(result.ConnectionStatus.Request, MethodInfo.GetCurrentMethod());
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)