/// <summary> /// 资讯搜索自动完成 /// </summary> public JsonResult SearchAutoComplete(string keyword, int topNumber) { //调用搜索器进行搜索 CmsSearcher cmsSearcher = (CmsSearcher)SearcherFactory.GetSearcher(CmsSearcher.CODE); IEnumerable <string> terms = cmsSearcher.AutoCompleteSearch(keyword, topNumber); var jsonResult = Json(terms.Select(t => new { tagName = t, tagNameWithHighlight = SearchEngine.Highlight(keyword, string.Join("", t.Take(34)), 100) }), JsonRequestBehavior.AllowGet); return(jsonResult); }