private AnalyzersDescriptor CreateAnalyzersDescriptor(int shingleCount, string tokenizer, string charHtmlFilter, TokenFiltersDescriptor tokenFilters) { var analyzers = new AnalyzersDescriptor(); for (var i = 1; i <= shingleCount; i++) { var actualIndex = i; var filterName = string.Format("{0}{1}", _filterPrefix, actualIndex); if (i != 1) { var filterDescriptor = new ShingleTokenFilterDescriptor().MinShingleSize(actualIndex) .MaxShingleSize(actualIndex) .OutputUnigrams(false) .OutputUnigramsIfNoShingles(false); tokenFilters.Shingle(filterName, desc => filterDescriptor); } var analyzerName = string.Format("{0}{1}", _analyzerPrefix, actualIndex); var analyzer = i != 1 ? new CustomAnalyzer { Filter = new List <string> { "lowercase", "word_filter", filterName, "filler_filter" }, Tokenizer = tokenizer, CharFilter = new List <string> { charHtmlFilter } } : new CustomAnalyzer { Filter = new List <string> { "lowercase", "word_filter", "filler_filter" }, Tokenizer = tokenizer, CharFilter = new List <string> { charHtmlFilter } }; analyzers.Custom(analyzerName, a => analyzer); } return(analyzers); }
public static TokenFiltersDescriptor AddAutoCompleteShingleFilter(this TokenFiltersDescriptor fd) { return(fd.Shingle(ElasticFilters.AutocompleteShingle, sh => sh.MinShingleSize(2).MaxShingleSize(4))); }