简体   繁体   中英

ElasticSearch - Nest - creating a template

I am using ElasticSearch version 6.4.1 and I am using it from my C# application using Nest library version 6.1.0 .

I an trying to create an Index Template using Nest without success.

The only documentation I found if this old documentation: Nest Templates

I can't find any documentation for the newer versions.

I did notice they have a method named PutIndexTemplate for the ElasticClient but again I can't find any documentation or examples on how to use it

I have seen this post: nst template example but looks like its broken as I get an compilation error on .Template

Ok I found the way it's done:

var putIndexTemplateResponse = m_ElasticClient.PutIndexTemplate("server_alerts", t => t
    .IndexPatterns("server_alerts*")
    .Mappings(m => m
        .Map("alert", tm => tm
            .Properties(p => p
                .Keyword(k => k
                    .Name("id")
                )
            )
        )
    )
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM