public static PropertiesDescriptor <T> UnicodeAnalyzer <T>(this PropertiesDescriptor <T> mappingDescriptor, Expression <Func <T, object> > selector, string analyzerName = "icu") where T : class { var uPropertyName = selector.GetUnicodeMemberName(true); return(mappingDescriptor.Text(p => p.Name(selector).CopyTo(c => c.Field(uPropertyName))) .Text(p => p.Name(uPropertyName).Analyzer(analyzerName))); }
private static PropertiesDescriptor <ErrorDocument> CreateMultiFieldsForAllStrings(PropertiesDescriptor <ErrorDocument> props) { var members = typeof(ErrorDocument) .GetProperties() .Where(x => x.PropertyType == typeof(string) && x.Name != "Id" && //id field is obviously excluded x.Name != "ErrorXml"//errorXML field is so long it has no indexer on it at all ); // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var m in members) { var name = m.Name; name = char.ToLowerInvariant(name[0]) + name.Substring(1);//lowercase the first character props .Text(s => s .Name(name) .Fields(pprops => pprops .Text(ps => ps.Name(name).Index(true)) .Text(ps => ps.Name(MultiFieldSuffix).Index(false)) ) ); } return(props); }
public static PropertiesDescriptor <T> UnicodeAnalyzer <T>(this PropertiesDescriptor <T> mappingDescriptor, string propertyName, string analyzerName = "icu") where T : class { var uPropertyName = propertyName.GetUnicodeMemberName(); return(mappingDescriptor.Text(p => p.Name(propertyName).CopyTo(c => c.Field(uPropertyName))) .Text(p => p.Name(uPropertyName).Analyzer(analyzerName))); }
public static PropertiesDescriptor <Document> AddContentFieldMapping(this PropertiesDescriptor <Document> propertiesDescriptor) { return(propertiesDescriptor .Text(t => t .Name(n => n.Content) )); }
private void FromExamineType(PropertiesDescriptor <Document> descriptor, FieldDefinition field) { switch (field.Type.ToLowerInvariant()) { case "date": case "datetimeoffset": descriptor.Date(s => s.Name(field.Name)); break; case "double": descriptor.Number(s => s.Name(field.Name).Type(NumberType.Double)); break; case "float": descriptor.Number(s => s.Name(field.Name).Type(NumberType.Float)); break; case "long": descriptor.Number(s => s.Name(field.Name).Type(NumberType.Long)); break; case "int": case "number": descriptor.Number(s => s.Name(field.Name).Type(NumberType.Integer)); break; default: descriptor.Text(s => s.Name(field.Name).Analyzer(FromLuceneAnalyzer(Analyzer))); break; } }
public static PropertiesDescriptor <T> AutoCompleteFields <T>(this PropertiesDescriptor <T> descriptor) where T : class { return(descriptor .Text(sub => sub.Name("default").Analyzer("default_autocomplete")) .Text(sub => sub.Name("stemmed").Analyzer("snowball_autocomplete")) .Text(sub => sub.Name("shingles").Analyzer("shingle_autocomplete")) .Text(sub => sub.Name("ngrams").Analyzer("ngram_autocomplete").SearchAnalyzer("search_autocomplete"))); }
public static PropertiesDescriptor <dynamic> DymTrigram(this PropertiesDescriptor <dynamic> ps) { return(ps .Text(tt => tt .Name(Strings.DidYouMeanTrigram) .Analyzer(ElasticAnalyzers.DidYouMeanTrigram) )); }
public PropertiesDescriptor <User> ConfigureMapping(PropertiesDescriptor <User> descriptor) { return(descriptor .Text(s => s.Name(l => l.UserName)) .Text(s => s.Name(l => l.Password)) .Text(s => s.Name(l => l.BioDescription)) .Number(s => s.Name(l => l.Roles)) .Number(s => s.Name(u => u.JoinDate).Type(NumberType.Double))); }
public static PropertiesDescriptor <dynamic> AutocompleteFilter(this PropertiesDescriptor <dynamic> ps) { return(ps .Text(tt => tt .Name(Strings.AutoCompleteFilter) .Analyzer(ElasticAnalyzers.AutoCompleteNgram) .SearchAnalyzer(ElasticAnalyzers.SearchAutoComplete) )); }
public static PropertiesDescriptor <dynamic> AutocompleteTerms(this PropertiesDescriptor <dynamic> ps) { return(ps .Text(tt => tt .Name(Strings.AutoCompleteTerms) .Fielddata() .Analyzer(ElasticAnalyzers.AutoCompleteShingle) )); }
public static PropertiesDescriptor <Person> AddAboutFieldMapping(this PropertiesDescriptor <Person> prpertiesDescriptor) { return(prpertiesDescriptor .Text(t => t .Name(n => n.About) .Fields(f => f .Text(ng => ng .Name("ngram") .Analyzer(Analyzers.NgramAnalyzer))))); }
public static PropertiesDescriptor <T> CreateTextFieldWithKeyword <T>(this PropertiesDescriptor <T> textDescriptor, Expression <Func <T, object> > fieldPath) where T : class { return(textDescriptor.Text(nameDesc => nameDesc .Name(fieldPath) .Fields(f => f .Keyword(pk => pk .Name("keyword") .Normalizer("removeNumbers") .IgnoreAbove(256))))); }
public static PropertiesDescriptor <T> CreateTextFieldWithKeyword <T>(this PropertiesDescriptor <T> textDescriptor, Expression <Func <T, object> > fieldPath, string fieldName) where T : class { return(textDescriptor.Text(nameDesc => nameDesc .Name(fieldPath) .Fields(f => f .Keyword(pk => pk .Name("keyword") .Normalizer(REMOVE_NUMBERS_NORMALIZER_NAME) .IgnoreAbove(256))))); }
public static PropertiesDescriptor <PersistentEvent> AddCopyToMappings(this PropertiesDescriptor <PersistentEvent> descriptor) { return(descriptor .Text(f => f.Name(EventIndexType.Alias.IpAddress).Analyzer(EventIndex.COMMA_WHITESPACE_ANALYZER)) .Text(f => f.Name(EventIndexType.Alias.OperatingSystem).AddKeywordField()) .Object <object>(f => f.Name("error").IncludeInAll().Properties(p1 => p1 .Keyword(f3 => f3.Name("code").Boost(1.1)) .Text(f3 => f3.Name("message").AddKeywordField()) .Text(f3 => f3.Name("type").Analyzer(EventIndex.TYPENAME_ANALYZER).SearchAnalyzer(EventIndex.WHITESPACE_LOWERCASE_ANALYZER).Boost(1.1).AddKeywordField()) .Text(f6 => f6.Name("targettype").Analyzer(EventIndex.TYPENAME_ANALYZER).SearchAnalyzer(EventIndex.WHITESPACE_LOWERCASE_ANALYZER).Boost(1.2).AddKeywordField()) .Text(f6 => f6.Name("targetmethod").Analyzer(EventIndex.TYPENAME_ANALYZER).SearchAnalyzer(EventIndex.WHITESPACE_LOWERCASE_ANALYZER).Boost(1.2).AddKeywordField())))); }
private static PropertiesDescriptor <DataDictionary> AddVersionMapping(this PropertiesDescriptor <DataDictionary> descriptor) { return(descriptor.Text(f2 => f2.Name(Event.KnownDataKeys.Version).RootAlias(EventIndexType.Alias.Version).Analyzer(EventIndex.VERSION_INDEX_ANALYZER).SearchAnalyzer(EventIndex.VERSION_SEARCH_ANALYZER).AddKeywordField())); }
public static PropertiesDescriptor <DataDictionary> AddLevelMapping(this PropertiesDescriptor <DataDictionary> descriptor) { return(descriptor.Text(f2 => f2.Name(Event.KnownDataKeys.Level).Analyzer(EventIndex.LOWER_KEYWORD_ANALYZER).AddKeywordField())); }
/// <summary> /// Obtient le mapping de champ Elastic pour une catégorie donnée. /// </summary> /// <param name="selector">Descripteur des propriétés.</param> /// <param name="field">Catégorie de champ.</param> /// <returns>Mapping de champ.</returns> /// <typeparam name="T">Type du document.</typeparam> public PropertiesDescriptor <T> AddField <T>(PropertiesDescriptor <T> selector, DocumentFieldDescriptor field) where T : class { var fieldName = field.FieldName; /* TODO Externaliser. */ switch (field.Category) { case SearchFieldCategory.Result: if (field.PropertyType == typeof(DateTime?)) { return(selector.Date(x => x .Name(fieldName) .Index(false) .Store(true))); } if (field.PropertyType == typeof(int?)) { return(selector.Number(x => x .Name(fieldName) .Type(NumberType.Integer) .Index(false) .Store(true))); } if (field.PropertyType == typeof(decimal?)) { return(selector.Number(x => x .Name(fieldName) .Type(NumberType.Double) .Index(false) .Store(true))); } return(selector.Text(x => x .Name(fieldName) .Index(false) .Store(true))); case SearchFieldCategory.Search: /* Champ de recherche textuelle full-text. */ return(selector.Text(x => x .Name(fieldName) .Index(true) .Store(false) .Analyzer("text_fr"))); case SearchFieldCategory.Security: /* Champ de filtrage de sécurité : listes de code. */ /* TODO : faire un mapping plus spécifique ? */ return(selector.Text(x => x .Name(fieldName) .Index(true) .Store(true) .Analyzer("text_fr"))); case SearchFieldCategory.Facet: /* Champ de facette. */ if (field.PropertyType == typeof(DateTime?)) { throw new ElasticException("Le type DateTime n'est pas supporté pour le champ de facette " + field.FieldName); } if (field.PropertyType == typeof(decimal?)) { return(selector.Number(x => x .Name(fieldName) .Index(true) .Store(false))); } return(selector.Keyword(x => x .Name(fieldName) .Index(true) .Store(false))); case SearchFieldCategory.ListFacet: return(selector.Text(x => x .Name(fieldName) .Index(true) .Store(false) .Analyzer("text_fr"))); case SearchFieldCategory.Sort: if (field.PropertyType == typeof(DateTime?)) { return(selector.Date(x => x .Name(fieldName) .Index(true) .Store(false))); } if (field.PropertyType == typeof(decimal?)) { return(selector.Number(x => x .Name(fieldName) .Index(true) .Store(false))); } return(selector.Keyword(x => x .Name(fieldName) .Index(true) .Store(false))); case SearchFieldCategory.Filter: /* Champ filtre. */ if (field.PropertyType == typeof(DateTime?)) { throw new ElasticException("Le type DateTime n'est pas supporté pour le champ de filtrage " + field.FieldName); } if (field.PropertyType == typeof(decimal?)) { return(selector.Number(x => x .Name(fieldName) .Index(true) .Store(false))); } return(selector.Keyword(x => x .Name(fieldName) .Index(true) .Store(false))); case SearchFieldCategory.Id: return(selector); default: throw new NotSupportedException("Category not supported : " + field.Category); } }
/// <summary> /// This field is added to allow to find taxonomies terms and partial matching ones in the exaxt search of the term in the query string query. /// </summary> /// <param name="pd"></param> /// <param name="metadataPropertyKey"></param> /// <returns></returns> public static PropertiesDescriptor <dynamic> ExactTaxonomyAnalyzer(this PropertiesDescriptor <dynamic> pd, string metadataPropertyKey) { return(pd.Text(ft => ft.Name("ExactTaxo" + Strings.Taxonomy).Analyzer(metadataPropertyKey.GetPreparedAnalyzerName(ElasticAnalyzers.TaxonomyTextPrefix) + "_exact_taxo") .SearchAnalyzer("keyword"))); }
public static PropertiesDescriptor <dynamic> DmpNgramAnalyzer(this PropertiesDescriptor <dynamic> pd) { return(pd.Text(tt => tt.DmpNgramAnalyzer())); }
public static PropertiesDescriptor <dynamic> DmpStandardEnglishAnalyzer(this PropertiesDescriptor <dynamic> pd) { return(pd.Text(tt => tt.DmpStandardEnglishAnalyzer())); }
private static PropertiesDescriptor <T> SetMultiField <T>(PropertiesDescriptor <T> f) where T : class { return(f.Text(tt => tt.Name("row").Fielddata()) .Keyword(kk => kk.Name("keyword"))); }
private static PropertiesDescriptor <DataDictionary> AddSubmissionMethodMapping(this PropertiesDescriptor <DataDictionary> descriptor) { return(descriptor.Text(f2 => f2.Name(Event.KnownDataKeys.SubmissionMethod).RootAlias(EventIndexType.Alias.SubmissionMethod).AddKeywordField())); }
public PropertiesDescriptor <Post> ConfigureMapping(PropertiesDescriptor <Post> descriptor) { return(descriptor.Text(t => t.Name(n => n.Title).Analyzer("cna"))); }
public static PropertiesDescriptor <dynamic> DmpNgramTaxonomyAnalyzer(this PropertiesDescriptor <dynamic> pd, string metadataPropertyKey) { return(pd.Text(ft => ft.Name("Ngram" + Strings.Taxonomy).Analyzer(metadataPropertyKey.GetPreparedAnalyzerName(ElasticAnalyzers.TaxonomyTextPrefix) + "_ngram") .SearchAnalyzer(metadataPropertyKey.GetPreparedAnalyzerName(ElasticAnalyzers.TaxonomyTextSearchPrefix)))); }