public override void Resolve(Q.Query <Displayable> query) { //ClaimsPrincipalDto.AddMarker("kpi.SearchQueryResolver.begin"); //if (!string.IsNullOrEmpty(query.DataQueryToken)) //{ // //NamedQueryFactory.Resolve(query); // return; //} var builder = new SearchQueryBuilder(query); var queryContainer = builder.GetQueryFor <Displayable>(query); var results = ElasticSearch.Search <ElasticTitleIndex>(queryContainer); //ClaimsPrincipalDto.Add("kpi.query", Encoding.UTF8.GetString(results.RequestInformation.Request)); query.Items = new List <Displayable>(); if (results.IsValid && results.Hits.Any()) { foreach (var displayable in results.Documents.Select(item => item.MapToDisplayable())) { query.Items.Add(displayable); } ExtractFilter(query, results); query.ResultSetCount = int.Parse(results.Total.ToString(CultureInfo.InvariantCulture)); } // ClaimsPrincipalDto.AddMarker("kpi.SearchQueryResolver.end"); }
/// <summary> /// 会员搜索 /// </summary> /// <param name="keyword">关键词</param> /// <param name="accountId">店铺id</param> /// <param name="masterId">总店id</param> /// <returns></returns> public List <UserSearchModel> UserBasic(string keyword, long accountId, long masterId) { var dict = new List <UserSearchModel>(); var oResult = _search.Search <UserBasic>(50, keyword, accountId, masterId); var userBasics = oResult as UserBasic[] ?? oResult.ToArray(); if (oResult != null && userBasics.Any()) { dict.AddRange(userBasics.Select(item => new UserSearchModel { uName = item.user_name, uNumber = item.user_cardno, uPhone = item.user_phone, uid = item.user_id, masterId = item.master_id })); } return(dict); }
public JsonResult Search(string text, bool isAccentVN = false) { if (!String.IsNullOrEmpty(text)) { text = Regex.Replace(HttpUtility.HtmlDecode(text), @"<(.|\n)*?>", ""); } if (isAccentVN) { text = _accent.GetAccentVN(text); } var lstData = _elastic.Search(text); var paginationSet = new PaginationSet <Question>() { Items = lstData, Page = 1, TotalCount = 1, TotalPages = 1 }; return(Json(paginationSet, JsonRequestBehavior.AllowGet)); }