public static CreateIndexDescriptor CreateBackofficeCourseDescriptor(this CreateIndexDescriptor descriptor)
 {
     return(descriptor?.Map <BackofficeCourse>(m => m.AutoMap().Properties(pr => pr
                                                                           .Keyword(i => i.Name("id"))
                                                                           .Keyword(i => i.Name("name"))
                                                                           )));
 }
示例#2
0
        private void TryCreateIndex(IndexName indexName)
        {
            lock (_lock)
            {
                if (!ElasticClient.Indices.Exists(indexName).Exists)
                {
                    var tracingIndex = new CreateIndexDescriptor(indexName);

                    tracingIndex.Map <SpanModel>(m => m
                                                 .AutoMap()
                                                 .Properties(p => p.Keyword(t => t.Name(n => n.TraceId)))
                                                 .Properties(p => p.Keyword(t => t.Name(n => n.SpanId)))
                                                 .Properties(p => p.Nested <SpanTag>(n => n.Name(name => name.Tags).AutoMap()
                                                                                     .Properties(tag => tag.Keyword(k => k.Name(n => n.Key)))
                                                                                     .Properties(tag => tag.Keyword(k => k.Name(n => n.Value)))
                                                                                     .Properties(tag => tag.Keyword(k => k.Name(n => n.Type)))))
                                                 .Properties(p => p.Nested <SpanLog>(n => n.Name(name => name.Logs).AutoMap()
                                                                                     .Properties(p => p.Nested <SpanTag>(n => n.Name(name => name.Fields).AutoMap()
                                                                                                                         .Properties(tag => tag.Keyword(k => k.Name(n => n.Value)))
                                                                                                                         .Properties(tag => tag.Keyword(k => k.Name(n => n.Type)))))))
                                                 .Properties(p => p.Nested <SpanProcess>(n => n.Name(name => name.Process).AutoMap().
                                                                                         Properties(p => p.Nested <SpanTag>(n => n.Name(name => name.Tags)
                                                                                                                            .AutoMap().Properties(tag => tag.Keyword(k => k.Name(n => n.Key)))
                                                                                                                            .Properties(tag => tag.Keyword(k => k.Name(n => n.Value)))
                                                                                                                            .Properties(tag => tag.Keyword(k => k.Name(n => n.Type)))
                                                                                                                            ))))
                                                 .Properties(p => p.Nested <SpanReference>(n => n.Name(name => name.References).AutoMap())));
                    var result = ElasticClient.Indices.Create(indexName, c => tracingIndex);
                    ElasticClient.Indices.BulkAlias(c => c.Add(a => a.Alias(QueryIndexName.Name).Index(indexName.Name)));
                }
            }
        }
示例#3
0
 public static CreateIndexDescriptor ProductMapping(this CreateIndexDescriptor descriptor)
 {
     return(descriptor.Map <Product>(m => m.Properties(p => p
                                                       //.Keyword(k => k.Name(n => n.Id))
                                                       .Text(t => t.Name(n => n.Name))
                                                       .Text(t => t.Name(n => n.ImageUrl))
                                                       .Number(t => t.Name(n => n.Price))
                                                       )
                                     ));
 }
 private void TryCreateIndex()
 {
     if (!ElasticClient.Indices.Exists(_IndexName).Exists)
     {
         var serviceOperation = new CreateIndexDescriptor(_IndexName);
         serviceOperation.Map <ServiceOperationModel>(m => m.AutoMap()
                                                      .Properties(p => p.Keyword(k => k.Name(c => c.Service)))
                                                      .Properties(p => p.Keyword(k => k.Name(c => c.Operation))));
         var r = ElasticClient.Indices.Create(serviceOperation);
     }
 }
示例#5
0
 private static CreateIndexDescriptor CreatePostIndex(CreateIndexDescriptor index)
 {
     return(index.Map <Post>(mapping =>
     {
         return mapping.AutoMap()
         .Properties(property => property.Keyword(key => key.Name(post => post.Network)))
         .Properties(property => property.Keyword(key => key.Name(post => post.Link)))
         .Properties(property => property.Keyword(key => key.Name(post => post.Lists)))
         .Properties(property => property.Keyword(key => key.Name(post => post.Author)));
     }));
 }
示例#6
0
 protected override ICreateIndexRequest CreateIndexSettings(CreateIndexDescriptor create) => create
 .Map <Project>(mm => mm.AutoMap());
 protected override CreateIndexDescriptor CreateMapping(CreateIndexDescriptor descriptor)
 {
     return(descriptor
            .Map <Person>(m => m
                          .Properties(p => p
                                      .Number(n => n
                                              .Name(person => person.Age)
                                              )
                                      .Text(t => t
                                            .Name(person => person.EyeColor)
                                            .Fields(f => f
                                                    .Keyword(kw => kw
                                                             .Name("keyword")
                                                             )
                                                    )
                                            )
                                      .Text(t => t
                                            .Name(person => person.Name)
                                            )
                                      .Text(t => t
                                            .Name(person => person.Gender)
                                            .Fields(f => f
                                                    .Keyword(kw => kw
                                                             .Name("keyword")
                                                             )
                                                    )
                                            )
                                      .Text(t => t
                                            .Name(person => person.Company)
                                            .Fields(f => f
                                                    .Keyword(kw => kw
                                                             .Name("keyword")
                                                             )
                                                    )
                                            )
                                      .Text(t => t
                                            .Name(person => person.Email)
                                            .Fields(f => f
                                                    .Keyword(kw => kw
                                                             .Name("keyword")
                                                             )
                                                    )
                                            )
                                      .Text(t => t
                                            .Name(person => person.Phone)
                                            )
                                      .Text(t => t
                                            .Name(person => person.Address)
                                            )
                                      .Text(t => t
                                            .Name(person => person.About)
                                            )
                                      .Date(t => t
                                            .Name(person => person.RegistrationDate)
                                            .Format("yyyy/MM/dd HH:mm:ss")
                                            )
                                      .GeoPoint(t => t
                                                .Name(person => person.Location)
                                                )
                                      )
                          ));
 }