//public static void CreateIndex() //{ // CreateIndex(defaultIndexName); //} public static void CreateIndex(ElasticClient client) { IndexSettings set = new IndexSettings(); set.NumberOfReplicas = 2; set.NumberOfShards = 25; // Create a Custom Analyzer ... var an = new CustomAnalyzer(); an.Tokenizer = "standard"; // ... with Filters from the StandardAnalyzer var filter = new List <string>(); filter.Add("lowercase"); filter.Add("czech_stop"); //an.Filter.Add("czech_keywords"); filter.Add("czech_stemmer"); filter.Add("asciifolding"); an.Filter = filter; // Add the Analyzer with a name set.Analysis = new Nest.Analysis() { Analyzers = new Analyzers(), TokenFilters = new TokenFilters(), }; set.Analysis.Analyzers.Add("default", an); set.Analysis.TokenFilters.Add("czech_stop", new StopTokenFilter() { StopWords = new string[] { "_czech_" } }); set.Analysis.TokenFilters.Add("czech_stemmer", new StemmerTokenFilter() { Language = "czech" }); IndexState idxSt = new IndexState(); idxSt.Settings = set; Nest.ICreateIndexResponse res = null; res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m.Map("data", mm => mm .Properties(ps => ps .Date(psn => psn.Name("DbCreated")) .Keyword(psn => psn.Name("DbCreatedBy")) ) ) ) ); }
public static void CreateIndex(ElasticClient client, IndexType idxTyp) { IndexSettings set = new IndexSettings(); set.NumberOfReplicas = 2; if (idxTyp == IndexType.DataSource) { set.NumberOfShards = 5; } else { set.NumberOfShards = 10; } // Create a Custom Analyzer ... var an = new CustomAnalyzer(); an.Tokenizer = "standard"; // ... with Filters from the StandardAnalyzer var filter = new List <string>(); filter.Add("lowercase"); filter.Add("czech_stop"); //an.Filter.Add("czech_keywords"); filter.Add("czech_stemmer"); filter.Add("asciifolding"); an.Filter = filter; // Add the Analyzer with a name set.Analysis = new Nest.Analysis() { Analyzers = new Analyzers(), TokenFilters = new TokenFilters(), }; set.Analysis.Analyzers.Add("default", an); set.Analysis.TokenFilters.Add("czech_stop", new StopTokenFilter() { StopWords = new string[] { "_czech_" } }); set.Analysis.TokenFilters.Add("czech_stemmer", new StemmerTokenFilter() { Language = "czech" }); IndexState idxSt = new IndexState(); idxSt.Settings = set; Nest.ICreateIndexResponse res = null; switch (idxTyp) { //case IndexType.VerejneZakazkyRaw2006: // res = client // .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i // .InitializeUsing(idxSt) // .Mappings(m => m // .Map<Lib.Data.VZ.VerejnaZakazka.ImportXMLpre2016.VerejnaZakazka2006>(map => map.AutoMap().DateDetection(false)) // .Map<Lib.Data.VZ.VerejnaZakazka.ImportXMLpre2016.CastiVerejneZakazky2006>(map => map.AutoMap().DateDetection(false)) // ) // ); // break; case IndexType.VerejneZakazky: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m .Map <Lib.Data.VZ.VerejnaZakazka>(map => map.AutoMap().DateDetection(false)) .Map <Lib.Data.VZ.ProfilZadavatele>(map => map.AutoMap().DateDetection(false)) ) ); break; case IndexType.Smlouvy: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m //.Map("_default_", mm => mm.TtlField(ttl => ttl.Enable(false))) .Map <Lib.Data.Smlouva>(map => map //.TtlField(ttl => ttl.Enable(false)) .AutoMap() .DateDetection(false) ) //.Map<Person>(map => map.AutoMap(maxRecursion: 1)) //.Map<VerejnaZakazka>(map => map.AutoMap(maxRecursion: 1).DateDetection(false)) ) ); break; case IndexType.Firmy: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m .Map <Data.Firma.Search.FirmaInElastic>(map => map.AutoMap(maxRecursion: 1)) ) ); break; case IndexType.Ucty: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m .Map <Lib.Data.TransparentniUcty.BankovniUcet>(map => map.AutoMap(maxRecursion: 1)) .Map <Lib.Data.TransparentniUcty.BankovniPolozka>(map => map.AutoMap(maxRecursion: 1)) ) ); break; case IndexType.Logs: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m .Map <Lib.Data.Logs.ProfilZadavateleDownload>(map => map.AutoMap(maxRecursion: 1)) ) ); break; case IndexType.VerejneZakazkyNaProfiluRaw: res = client .CreateIndex(client.ConnectionSettings.DefaultIndex, i => i .InitializeUsing(idxSt) .Mappings(m => m .Map <Lib.Data.External.ProfilZadavatelu.ZakazkaRaw>(map => map .Properties(p => p .Keyword(k => k.Name(n => n.ZakazkaId)) .Keyword(k => k.Name(n => n.Profil)) .Date(k => k.Name(n => n.LastUpdate)) ) ) ) ); break; } //Console.WriteLine(res.IsValid); }