diff --git a/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs b/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs index e791237f334..c53a2e3fdb7 100644 --- a/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs @@ -56,6 +56,13 @@ public interface IWordDelimiterGraphTokenFilter : ITokenFilter [JsonFormatter(typeof(NullableStringBooleanFormatter))] bool? GenerateWordParts { get; set; } + /// + /// If true, the filter skips tokens with a keyword attribute of true. Defaults to false. + /// + [DataMember(Name = "ignore_keywords")] + [JsonFormatter(typeof(NullableStringBooleanFormatter))] + bool? IgnoreKeywords { get; set; } + /// /// If true includes original words in subwords: "500-42" ⇒ "500-42" "500" "42". Defaults to false. /// @@ -133,6 +140,9 @@ public WordDelimiterGraphTokenFilter() : base("word_delimiter_graph") { } /// public bool? GenerateWordParts { get; set; } + /// + public bool? IgnoreKeywords { get; set; } + /// public bool? PreserveOriginal { get; set; } @@ -169,8 +179,8 @@ public class WordDelimiterGraphTokenFilterDescriptor bool? IWordDelimiterGraphTokenFilter.CatenateWords { get; set; } bool? IWordDelimiterGraphTokenFilter.GenerateNumberParts { get; set; } bool? IWordDelimiterGraphTokenFilter.GenerateWordParts { get; set; } + bool? IWordDelimiterGraphTokenFilter.IgnoreKeywords { get; set; } bool? IWordDelimiterGraphTokenFilter.PreserveOriginal { get; set; } - IEnumerable IWordDelimiterGraphTokenFilter.ProtectedWords { get; set; } string IWordDelimiterGraphTokenFilter.ProtectedWordsPath { get; set; } bool? IWordDelimiterGraphTokenFilter.SplitOnCaseChange { get; set; } @@ -187,6 +197,14 @@ public WordDelimiterGraphTokenFilterDescriptor GenerateWordParts(bool? generateW public WordDelimiterGraphTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => Assign(generateNumberParts, (a, v) => a.GenerateNumberParts = v); + /// + /// Configure whether the filter will skip tokens with a keyword attribute of true. + /// (Optional) When not configured, this defaults to false in Elasticsearch. + /// + /// If true, the filter skips tokens with a keyword attribute of true. + public WordDelimiterGraphTokenFilterDescriptor IgnoreKeywords(bool? ignoreKeywords = true) => + Assign(ignoreKeywords, (a, v) => a.IgnoreKeywords = v); + /// public WordDelimiterGraphTokenFilterDescriptor CatenateWords(bool? catenateWords = true) => Assign(catenateWords, (a, v) => a.CatenateWords = v); diff --git a/tests/Tests/Analysis/TokenFilters/TokenFilterTests.cs b/tests/Tests/Analysis/TokenFilters/TokenFilterTests.cs index 74276bd3c31..33a3d4a7ef1 100644 --- a/tests/Tests/Analysis/TokenFilters/TokenFilterTests.cs +++ b/tests/Tests/Analysis/TokenFilters/TokenFilterTests.cs @@ -923,6 +923,7 @@ public class WordDelimiterGraphTests : TokenFilterAssertionBase