private static IPromise <IProperties> SetupProperties(PropertiesDescriptor <Doc> properties) { return(properties.Keyword(k => k .Name(doc => doc.Name)) .Text(t => t .Name(doc => doc.Content) .Analyzer(Analyzer.CustomAnalyzer))); }
protected override void FromExamineType(PropertiesDescriptor <Document> descriptor, FieldDefinition field) { if (KeywordFields.Contains(field.Name)) { descriptor.Keyword(s => s.Name(field.Name)); return; } base.FromExamineType(descriptor, field); }
public override PropertiesDescriptor <Document> CreateFieldsMapping(PropertiesDescriptor <Document> descriptor, FieldDefinitionCollection fieldDefinitionCollection) { descriptor.Keyword(s => s.Name("Id")); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.ItemIdFieldName))); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.ItemTypeFieldName))); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.CategoryFieldName))); foreach (FieldDefinition field in fieldDefinitionCollection) { FromExamineType(descriptor, field); } var docArgs = new MappingOperationEventArgs(descriptor); onMapping(docArgs); return(descriptor); }
private PropertiesDescriptor <TRoyal> RoyalProps <TRoyal>(PropertiesDescriptor <TRoyal> props) where TRoyal : class, IRoyal => props.Keyword(s => s.Name(p => p.Name));
private static PropertiesDescriptor <Developer> DeveloperProperties(PropertiesDescriptor <Developer> props) => props .Keyword(s => s .Name(p => p.OnlineHandle) ) .Keyword(s => s .Name(p => p.Gender) ) .Text(s => s .Name(p => p.FirstName) .TermVector(TermVectorOption.WithPositionsOffsetsPayloads) ) .Ip(s => s .Name(p => p.IPAddress) ) .GeoPoint(g => g .Name(p => p.Location) ) .Object <GeoIp>(o => o .Name(p => p.GeoIp) );
private static PropertiesDescriptor <Tag> TagProperties(PropertiesDescriptor <Tag> props) => props .Keyword(s => s .Name(p => p.Name) .Fields(f => f .Text(st => st .Name("vectors") .TermVector(TermVectorOption.WithPositionsOffsetsPayloads) ) ) );
public static PropertiesDescriptor <Project> ProjectProperties(PropertiesDescriptor <Project> props) => props .Keyword(s => s .Name(p => p.Name) .Store() .Fields(fs => fs .Text(ss => ss .Name("standard") .Analyzer("standard") ) .Completion(cm => cm .Name("suggest") ) ) ) .Text(s => s .Name(p => p.Description) .Fielddata() .Fields(f => f .Text(t => t .Name("shingle") .Analyzer("shingle") ) ) ) .Date(d => d .Store() .Name(p => p.StartedOn) ) .Text(d => d .Store() .Name(p => p.DateString) ) .Keyword(d => d .Name(p => p.State) .Fields(fs => fs .Text(st => st .Name("offsets") .IndexOptions(IndexOptions.Offsets) ) .Keyword(sk => sk .Name("keyword") ) ) ) .Nested <Tag>(mo => mo .AutoMap() .Name(p => p.Tags) .Properties(TagProperties) ) .Object <Developer>(o => o .AutoMap() .Name(p => p.LeadDeveloper) .Properties(DeveloperProperties) ) .GeoPoint(g => g .Name(p => p.Location) ) .Completion(cm => cm .Name(p => p.Suggest) .Contexts(cx => cx .Category(c => c .Name("color") ) ) ) .Number(n => n .Name(p => p.NumberOfCommits) .Store() ) .Object <Dictionary <string, Metadata> >(o => o .Name(p => p.Metadata) );
public static PropertiesDescriptor <TProject> ProjectProperties <TProject>(PropertiesDescriptor <TProject> props) where TProject : Project { props .Join(j => j .Name(n => n.Join) .Relations(r => r .Join <Project, CommitActivity>() ) ) .Keyword(d => d.Name(p => p.Type)) .Keyword(s => s .Name(p => p.Name) .Store() .Fields(fs => fs .Text(ss => ss .Name("standard") .Analyzer("standard") ) .Completion(cm => cm .Name("suggest") ) ) ) .Text(s => s .Name(p => p.Description) .Fielddata() .Fields(f => f .Text(t => t .Name("shingle") .Analyzer("shingle") ) ) ) .Date(d => d .Store() .Name(p => p.StartedOn) ) .Text(d => d .Store() .Name(p => p.DateString) ) .Keyword(d => d .Name(p => p.State) .Fields(fs => fs .Text(st => st .Name("offsets") .IndexOptions(IndexOptions.Offsets) ) .Keyword(sk => sk .Name("keyword") ) ) ) .Nested <Tag>(mo => mo .AutoMap() .Name(p => p.Tags) .Properties(TagProperties) ) .Object <Developer>(o => o .AutoMap() .Name(p => p.LeadDeveloper) .Properties(DeveloperProperties) ) .GeoPoint(g => g .Name(p => p.LocationPoint) ) .GeoShape(g => g .Name(p => p.LocationShape) ) .Shape(g => g .Name(p => p.ArbitraryShape) ) .Completion(cm => cm .Name(p => p.Suggest) .Contexts(cx => cx .Category(c => c .Name("color") ) .GeoLocation(c => c .Name("geo") .Precision(1) ) ) ) .Scalar(p => p.NumberOfCommits, n => n.Store()) .Scalar(p => p.NumberOfContributors, n => n.Store()) .Object <Dictionary <string, Metadata> >(o => o .Name(p => p.Metadata) ) .RankFeature(rf => rf .Name(p => p.Rank) .PositiveScoreImpact() ); if (TestConfiguration.Instance.InRange(">=7.3.0")) { props.Flattened(f => f .Name(p => p.Labels) ); } else { props.Object <Labels>(f => f .Name(p => p.Labels) .Enabled(false) ); } if (TestConfiguration.Instance.InRange(">=7.7.0")) { props.ConstantKeyword(f => f .Name(p => p.VersionControl) ); } else { props.Keyword(f => f .Name(p => p.VersionControl) ); } return(props); }
private static PropertiesDescriptor<Developer> DeveloperProperties(PropertiesDescriptor<Developer> props) => props .Keyword(s => s .Name(p => p.OnlineHandle) ) .Keyword(s => s .Name(p => p.Gender) ) .Text(s => s .Name(p => p.FirstName) .TermVector(TermVectorOption.WithPositionsOffsetsPayloads) ) .Ip(s => s .Name(p => p.IPAddress) ) .GeoPoint(g => g .Name(p => p.Location) ) .Object<GeoIp>(o => o .Name(p => p.GeoIp) );
private static PropertiesDescriptor<Tag> TagProperties(PropertiesDescriptor<Tag> props) => props .Keyword(s => s .Name(p => p.Name) .Fields(f => f .Text(st => st .Name("vectors") .TermVector(TermVectorOption.WithPositionsOffsetsPayloads) ) ) );
public static PropertiesDescriptor<Project> ProjectProperties(PropertiesDescriptor<Project> props) => props .Keyword(s => s .Name(p => p.Name) .Store() .Fields(fs => fs .Text(ss => ss .Name("standard") .Analyzer("standard") ) .Completion(cm => cm .Name("suggest") ) ) ) .Text(s=>s .Name(p=>p.Description) .Fielddata() ) .Date(d => d .Store() .Name(p => p.StartedOn) ) .Text(d => d .Store() .Name(p => p.DateString) ) .Keyword(d => d .Name(p => p.State) .Fields(fs => fs .Text(st => st .Name("offsets") .IndexOptions(IndexOptions.Offsets) ) ) ) .Nested<Tag>(mo => mo .AutoMap() .Name(p => p.Tags) .Properties(TagProperties) ) .Object<Developer>(o => o .AutoMap() .Name(p => p.LeadDeveloper) .Properties(DeveloperProperties) ) .GeoPoint(g => g .Name(p => p.Location) ) .Completion(cm => cm .Name(p => p.Suggest) .Contexts(cx => cx .Category(c => c .Name("color") ) ) ) .Number(n => n .Name(p => p.NumberOfCommits) .Store() ) .Object<Dictionary<string,Metadata>>(o => o .Name(p => p.Metadata) );
public static PropertiesDescriptor <DataDictionary> AddSubmissionMethodMapping(this PropertiesDescriptor <DataDictionary> descriptor) { return(descriptor.Keyword(f2 => f2.Name(Event.KnownDataKeys.SubmissionMethod).IgnoreAbove(1024))); }
/// <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); } }
public static PropertiesDescriptor <dynamic> EdgeKeyword(this PropertiesDescriptor <dynamic> pd) { return(pd.Keyword(kk => kk.Name(NodeNames.Edge))); }