// GET: Person public void Index() { List <PersonModel> person = new List <PersonModel>(); var person1 = new PersonModel { Id = "3", Firstname = "Dewa", Lastname = "Pandu" }; var person2 = new PersonModel { Id = "2", Firstname = "Rusdy", Lastname = "Hafid" }; person.Add(person1); person.Add(person2); //JavaScriptSerializer js = new JavaScriptSerializer(); //string json = js.Serialize(person); //return json; var index = elastic.client().IndexMany(person); }
// GET: Attach public void Index() { var indexResponse = elastic.client().CreateIndex("attachdoc", c => c .Settings(s => s .Analysis(an => an .Analyzers(ad => ad .Custom("windows_path_hierarchy_analyzer", ca => ca .Tokenizer("windows_path_hierarchy_tokenizer") ) ) .Tokenizers(t => t .PathHierarchy("windows_path_hierarchy_tokenizer", ph => ph .Delimiter('\\') ) ) ) ) .Mappings(m => m .Map <AttachModel>(mp => mp .AutoMap() .AllField(all => all .Enabled(false) ) .Properties(ps => ps .Text(s => s .Name(n => n.Path) .Analyzer("windows_path_hierarchy_analyzer") ) .Object <Attachment>(at => at .Name(n => n.Attachment) .AutoMap() ) ) ) ) ); elastic.client().PutPipeline("attachments", p => p .Description("Document attachment pipeline") .Processors(pr => pr .Attachment <AttachModel>(am => am .Field(f => f.Content) .TargetField(f => f.Attachment) ) .Remove <AttachModel>(r => r .Field(f => f.Content) ) ) ); var directory = Directory.GetCurrentDirectory(); var base64File = Convert.ToBase64String(System.IO.File.ReadAllBytes(Path.Combine(directory, "test.docx"))); elastic.client().Index(new AttachModel { Id = 1, Path = @"\\Documents\test.docx", Content = base64File }, i => i.Pipeline("attachments")); //return base64File; }