public static TokenFiltersDescriptor AddTaxonomyFilters(this TokenFiltersDescriptor fd, IEnumerable <MetadataProperty> metadataProperties)
        {
            foreach (var metadataProperty in metadataProperties)
            {
                if (metadataProperty == null || !metadataProperty.Properties.ContainsKey(Strings.Taxonomy))
                {
                    continue;
                }
                IDictionary <TaxonomyResultDTO, IList <TaxonomyResultDTO> > dictionary = TaxonomyTransformer.BuildFlatDictionary(metadataProperty.Properties[Strings.Taxonomy]);

                string autoPhraseKey = metadataProperty.Key.GetPreparedAnalyzerName(ElasticFilters.AutoPhrasePrefix);
                string vocabularyKey = metadataProperty.Key.GetPreparedAnalyzerName(ElasticFilters.VocabularyPrefix);

                fd.AddAutoPhraseFilter(dictionary, autoPhraseKey);
                fd.AddVocabularyFilter(dictionary, vocabularyKey);
            }
            return(fd);
        }
        public static AnalyzersDescriptor AddTaxonomyAnalyzers(this AnalyzersDescriptor ad, IEnumerable <MetadataProperty> metadataProperties)
        {
            foreach (var metadataProperty in metadataProperties)
            {
                if (metadataProperty == null || !metadataProperty.Properties.ContainsKey(Strings.Taxonomy))
                {
                    continue;
                }

                // TODO SL: remove unused
                IDictionary <TaxonomyResultDTO, IList <TaxonomyResultDTO> > dictionary = TaxonomyTransformer.BuildFlatDictionary(metadataProperty.Properties[Strings.Taxonomy]);

                var taxonomyTextKey       = metadataProperty.Key.GetPreparedAnalyzerName(ElasticAnalyzers.TaxonomyTextPrefix);
                var taxonomyTextSearchKey = metadataProperty.Key.GetPreparedAnalyzerName(ElasticAnalyzers.TaxonomyTextSearchPrefix);

                string autoPhraseKey = metadataProperty.Key.GetPreparedAnalyzerName(ElasticFilters.AutoPhrasePrefix);
                string vocabularyKey = metadataProperty.Key.GetPreparedAnalyzerName(ElasticFilters.VocabularyPrefix);

                ad.AddStandardTokenizerFilter(taxonomyTextKey, ElasticFilters.Lowercase, autoPhraseKey, vocabularyKey);
                ad.AddStandardTokenizerFilter(taxonomyTextKey + "_ngram", ElasticFilters.Lowercase, autoPhraseKey, vocabularyKey, ElasticFilters.Ngram);
                ad.AddStandardTokenizerFilter(taxonomyTextKey + "_exact_taxo", ElasticFilters.Lowercase, autoPhraseKey, vocabularyKey, ElasticFilters.FilterWordDelimiter, ElasticFilters.Ngram);
                ad.AddStandardTokenizerFilter(taxonomyTextSearchKey, ElasticFilters.Lowercase, autoPhraseKey);
            }
            return(ad);
        }