public async void GetRefreshIndex() { List <Topic> topics = _context.Topic.ToList(); List <TopicReply> topicreplies = _context.TopicReply.ToList(); List <Category> categories = _context.Category.ToList(); List <ESSearchItem> searchItems = new List <ESSearchItem>(); foreach (var item in topics) { searchItems.Add(new ESSearchItem(item)); } foreach (var item in topicreplies) { searchItems.Add(new ESSearchItem(item)); } foreach (var item in categories) { searchItems.Add(new ESSearchItem(item)); } await _connectionToEs.EsClient().Indices.DeleteAsync("forumtestindex"); var response = await _connectionToEs.EsClient().IndexManyAsync(searchItems, "forumtestindex"); }
public JsonResult DataSearch(string jobtitle, string nationalIDNumber) { if (!string.IsNullOrEmpty(jobtitle) && !string.IsNullOrEmpty(nationalIDNumber)) { var responsedata = _connectionToEs.EsClient().Search <Humanresources>(s => s .Index("humanresources") .Type("doc") .Size(50) .Query(q => q .Match(m => m .Field(f => f.jobtitle) .Query(jobtitle) ) && q .Match(m => m .Field(f => f.nationalidnumber) .Query(nationalIDNumber) )) ); var datasend = (from hits in responsedata.Hits select hits.Source).ToList(); return(Json(new { datasend, responsedata.Took }, behavior: JsonRequestBehavior.AllowGet)); } else if (!string.IsNullOrEmpty(jobtitle)) { var responsedata = _connectionToEs.EsClient().Search <Humanresources>(s => s .Index("humanresources") .Type("doc") .Size(50) .Query(q => q .Match(m => m .Field(f => f.jobtitle) .Query(jobtitle) ))); var datasend = (from hits in responsedata.Hits select hits.Source).ToList(); return(Json(new { datasend, responsedata.Took }, behavior: JsonRequestBehavior.AllowGet)); } else if (!string.IsNullOrEmpty(nationalIDNumber)) { var responsedata = _connectionToEs.EsClient().Search <Humanresources>(s => s .Index("humanresources") .Type("doc") .Size(50) .Query(q => q .Match(m => m .Field(f => f.nationalidnumber) .Query(nationalIDNumber) ))); var datasend = (from hits in responsedata.Hits select hits.Source).ToList(); return(Json(new { datasend, responsedata.Took }, behavior: JsonRequestBehavior.AllowGet)); } return(Json(data: null, behavior: JsonRequestBehavior.AllowGet)); }
public JsonResult DataSearch(string FoodItem) { var responsedata = _connectionToEs.EsClient().Search <FoodMenuApplicationModel>(s => s .Index("onlinefoodbooking") .Type("foodmenu") .Size(50) .Query(q => q .Match(m => m .Field(f => f.FoodItem) .Query(FoodItem) ) ) ); var datasend = (from hits in responsedata.Hits select hits.Source).ToList(); return(Json(new { datasend, responsedata.Took }, behavior: JsonRequestBehavior.AllowGet)); }