|
| 1 | +using System.Collections.Generic; |
| 2 | +using Newtonsoft.Json; |
| 3 | + |
| 4 | +namespace Nest |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// Named word_delimiter, it Splits words into subwords and performs optional transformations on subword groups. |
| 8 | + /// Unlike the word_delimiter this token filter named word_delimiter_graph correctly handles multi terms expansion at query time. |
| 9 | + /// </summary> |
| 10 | + public interface IWordDelimiterGraphTokenFilter : ITokenFilter |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// If true causes parts of words to be generated: "PowerShot" ⇒ "Power" "Shot". Defaults to true. |
| 14 | + /// </summary> |
| 15 | + [JsonProperty("generate_word_parts")] |
| 16 | + bool? GenerateWordParts { get; set; } |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// If true causes number subwords to be generated: "500-42" ⇒ "500" "42". Defaults to true. |
| 20 | + /// </summary> |
| 21 | + [JsonProperty("generate_number_parts")] |
| 22 | + bool? GenerateNumberParts { get; set; } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// If true causes maximum runs of word parts to be catenated: "wi-fi" ⇒ "wifi". Defaults to false. |
| 26 | + /// </summary> |
| 27 | + [JsonProperty("catenate_words")] |
| 28 | + bool? CatenateWords { get; set; } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// If true causes maximum runs of number parts to be catenated: "500-42" ⇒ "50042". Defaults to false. |
| 32 | + /// </summary> |
| 33 | + [JsonProperty("catenate_numbers")] |
| 34 | + bool? CatenateNumbers { get; set; } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// If true causes all subword parts to be catenated: "wi-fi-4000" ⇒ "wifi4000". Defaults to false. |
| 38 | + /// </summary> |
| 39 | + [JsonProperty("catenate_all")] |
| 40 | + bool? CatenateAll { get; set; } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// If true causes "PowerShot" to be two tokens; ("Power-Shot" remains two parts regards). Defaults to true. |
| 44 | + /// </summary> |
| 45 | + [JsonProperty("split_on_case_change")] |
| 46 | + bool? SplitOnCaseChange { get; set; } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// If true includes original words in subwords: "500-42" ⇒ "500-42" "500" "42". Defaults to false. |
| 50 | + /// </summary> |
| 51 | + [JsonProperty("preserve_original")] |
| 52 | + bool? PreserveOriginal { get; set; } |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// If true causes "j2se" to be three tokens; "j" "2" "se". Defaults to true. |
| 56 | + /// </summary> |
| 57 | + [JsonProperty("split_on_numerics")] |
| 58 | + bool? SplitOnNumerics { get; set; } |
| 59 | + |
| 60 | + /// <summary> |
| 61 | + /// If true causes trailing "'s" to be removed for each subword: "O’Neil’s" ⇒ "O", "Neil". Defaults to true. |
| 62 | + /// </summary> |
| 63 | + [JsonProperty("stem_english_possessive")] |
| 64 | + bool? StemEnglishPossessive { get; set; } |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// A list of protected words from being delimiter. |
| 68 | + /// </summary> |
| 69 | + [JsonProperty("protected_words")] |
| 70 | + IEnumerable<string> ProtectedWords { get; set; } |
| 71 | + |
| 72 | + /// <summary> |
| 73 | + ///protected_words_path which resolved to a file configured with protected words (one on each line). |
| 74 | + /// Automatically resolves to config/ based location if exists. |
| 75 | + /// </summary> |
| 76 | + [JsonProperty("protected_words_path ")] |
| 77 | + string ProtectedWordsPath { get; set; } |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// A custom type mapping table |
| 81 | + /// </summary> |
| 82 | + [JsonProperty("type_table")] |
| 83 | + IEnumerable<string> TypeTable { get; set; } |
| 84 | + |
| 85 | + /// <summary> |
| 86 | + /// A path to a custom type mapping table file |
| 87 | + /// </summary> |
| 88 | + [JsonProperty("type_table_path")] |
| 89 | + string TypeTablePath { get; set; } |
| 90 | + |
| 91 | + } |
| 92 | + |
| 93 | + /// <inheritdoc/> |
| 94 | + public class WordDelimiterGraphTokenFilter : TokenFilterBase, IWordDelimiterGraphTokenFilter |
| 95 | + { |
| 96 | + public WordDelimiterGraphTokenFilter() : base("word_delimiter_graph") { } |
| 97 | + |
| 98 | + /// <inheritdoc/> |
| 99 | + public bool? GenerateWordParts { get; set; } |
| 100 | + |
| 101 | + /// <inheritdoc/> |
| 102 | + public bool? GenerateNumberParts { get; set; } |
| 103 | + |
| 104 | + /// <inheritdoc/> |
| 105 | + public bool? CatenateWords { get; set; } |
| 106 | + |
| 107 | + /// <inheritdoc/> |
| 108 | + public bool? CatenateNumbers { get; set; } |
| 109 | + |
| 110 | + /// <inheritdoc/> |
| 111 | + public bool? CatenateAll { get; set; } |
| 112 | + |
| 113 | + /// <inheritdoc/> |
| 114 | + public bool? SplitOnCaseChange { get; set; } |
| 115 | + |
| 116 | + /// <inheritdoc/> |
| 117 | + public bool? PreserveOriginal { get; set; } |
| 118 | + |
| 119 | + /// <inheritdoc/> |
| 120 | + public bool? SplitOnNumerics { get; set; } |
| 121 | + |
| 122 | + /// <inheritdoc/> |
| 123 | + public bool? StemEnglishPossessive { get; set; } |
| 124 | + |
| 125 | + /// <inheritdoc/> |
| 126 | + public IEnumerable<string> ProtectedWords { get; set; } |
| 127 | + |
| 128 | + /// <inheritdoc/> |
| 129 | + public string ProtectedWordsPath { get; set; } |
| 130 | + |
| 131 | + /// <inheritdoc/> |
| 132 | + public IEnumerable<string> TypeTable { get; set; } |
| 133 | + |
| 134 | + /// <inheritdoc/> |
| 135 | + public string TypeTablePath { get; set; } |
| 136 | + } |
| 137 | + |
| 138 | + ///<inheritdoc/> |
| 139 | + public class WordDelimiterGraphTokenFilterDescriptor |
| 140 | + : TokenFilterDescriptorBase<WordDelimiterGraphTokenFilterDescriptor, IWordDelimiterGraphTokenFilter>, IWordDelimiterGraphTokenFilter |
| 141 | + { |
| 142 | + protected override string Type => "word_delimiter_graph"; |
| 143 | + |
| 144 | + IEnumerable<string> IWordDelimiterGraphTokenFilter.ProtectedWords { get; set; } |
| 145 | + string IWordDelimiterGraphTokenFilter.ProtectedWordsPath { get; set; } |
| 146 | + IEnumerable<string> IWordDelimiterGraphTokenFilter.TypeTable { get; set; } |
| 147 | + string IWordDelimiterGraphTokenFilter.TypeTablePath { get; set; } |
| 148 | + bool? IWordDelimiterGraphTokenFilter.GenerateWordParts { get; set; } |
| 149 | + bool? IWordDelimiterGraphTokenFilter.GenerateNumberParts { get; set; } |
| 150 | + bool? IWordDelimiterGraphTokenFilter.CatenateWords { get; set; } |
| 151 | + bool? IWordDelimiterGraphTokenFilter.CatenateNumbers { get; set; } |
| 152 | + bool? IWordDelimiterGraphTokenFilter.CatenateAll { get; set; } |
| 153 | + bool? IWordDelimiterGraphTokenFilter.SplitOnCaseChange { get; set; } |
| 154 | + bool? IWordDelimiterGraphTokenFilter.PreserveOriginal { get; set; } |
| 155 | + bool? IWordDelimiterGraphTokenFilter.SplitOnNumerics { get; set; } |
| 156 | + bool? IWordDelimiterGraphTokenFilter.StemEnglishPossessive { get; set; } |
| 157 | + |
| 158 | + ///<inheritdoc/> |
| 159 | + public WordDelimiterGraphTokenFilterDescriptor GenerateWordParts(bool? generateWordParts = true) => Assign(a => a.GenerateWordParts = generateWordParts); |
| 160 | + |
| 161 | + ///<inheritdoc/> |
| 162 | + public WordDelimiterGraphTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => Assign(a => a.GenerateNumberParts = generateNumberParts); |
| 163 | + |
| 164 | + ///<inheritdoc/> |
| 165 | + public WordDelimiterGraphTokenFilterDescriptor CatenateWords(bool? catenateWords = true) => Assign(a => a.CatenateWords = catenateWords); |
| 166 | + |
| 167 | + ///<inheritdoc/> |
| 168 | + public WordDelimiterGraphTokenFilterDescriptor CatenateNumbers(bool? catenateNumbers = true) => Assign(a => a.CatenateNumbers = catenateNumbers); |
| 169 | + |
| 170 | + ///<inheritdoc/> |
| 171 | + public WordDelimiterGraphTokenFilterDescriptor CatenateAll(bool? catenateAll = true) => Assign(a => a.CatenateAll = catenateAll); |
| 172 | + |
| 173 | + ///<inheritdoc/> |
| 174 | + public WordDelimiterGraphTokenFilterDescriptor SplitOnCaseChange(bool? split = true) => Assign(a => a.SplitOnCaseChange = split); |
| 175 | + |
| 176 | + ///<inheritdoc/> |
| 177 | + public WordDelimiterGraphTokenFilterDescriptor SplitOnNumerics(bool? split = true) => Assign(a => a.SplitOnNumerics = split); |
| 178 | + |
| 179 | + ///<inheritdoc/> |
| 180 | + public WordDelimiterGraphTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); |
| 181 | + |
| 182 | + ///<inheritdoc/> |
| 183 | + public WordDelimiterGraphTokenFilterDescriptor StemEnglishPossessive(bool? stem = true) => Assign(a => a.StemEnglishPossessive = stem); |
| 184 | + |
| 185 | + ///<inheritdoc/> |
| 186 | + public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(IEnumerable<string> protectedWords) => Assign(a => a.ProtectedWords = protectedWords); |
| 187 | + |
| 188 | + ///<inheritdoc/> |
| 189 | + public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(params string[] protectedWords) => Assign(a => a.ProtectedWords = protectedWords); |
| 190 | + |
| 191 | + ///<inheritdoc/> |
| 192 | + public WordDelimiterGraphTokenFilterDescriptor ProtectedWordsPath(string path) => Assign(a => a.ProtectedWordsPath = path); |
| 193 | + |
| 194 | + ///<inheritdoc/> |
| 195 | + public WordDelimiterGraphTokenFilterDescriptor TypeTable(IEnumerable<string> typeTable) => Assign(a => a.TypeTable = typeTable); |
| 196 | + |
| 197 | + ///<inheritdoc/> |
| 198 | + public WordDelimiterGraphTokenFilterDescriptor TypeTable(params string[] typeTable) => Assign(a => a.TypeTable = typeTable); |
| 199 | + |
| 200 | + ///<inheritdoc/> |
| 201 | + public WordDelimiterGraphTokenFilterDescriptor TypeTablePath(string path) => Assign(a => a.TypeTablePath = path); |
| 202 | + |
| 203 | + } |
| 204 | + |
| 205 | +} |
0 commit comments