コード例 #1
0
        public JsonResult Build(string projectCode)
        {
            var responsedata = _connectionToEs.ElasticSerchClient().Search <Projectmaster>(s => s
                                                                                           .Index(_indexName)
                                                                                           .Type(_typeName)
                                                                                           .Size(50)
                                                                                           .Query(q => q
                                                                                                  .Match(m => m
                                                                                                         .Field(f => f.projectcode)
                                                                                                         .Query(projectCode)
                                                                                                         )
                                                                                                  )
                                                                                           );

            var data = (from hits in responsedata.Hits
                        select hits.Source).ToList();

            data.Insert(0, new Projectmaster
            {
                projectname      = "Project Name",
                projectcode      = "Project Code",
                NatureofIndustry = "Nature of Industory"
            });

            return(new JsonResult
            {
                Data = GetJsonModel(data)
            });
        }
コード例 #2
0
        public JsonResult Build(Projectmaster model)
        {
            var response = _connectionToEs.ElasticSerchClient().Index(model, i => i
                                                                      .Index(_indexName)
                                                                      .Type(_typeName)
                                                                      .Id(Guid.NewGuid()));

            return(new JsonResult
            {
                Data = GetJsonModel(response, model)
            });
        }