代码:
string keyword =RemoveHTML(GetString("Keyword")); StringBuilder strWhere=new StringBuilder("isaudit=1 "+(typeId==0?"": "and TypeID=" + typeId)); if (!string.IsNullOrWhiteSpace(keyword)) { if (keyword.Length > 2) { /*中文分词功能*/ JiebaSegmenter jieba = new JiebaSegmenter(); var segments = jieba.CutForSearch(keyword); strWhere.Append(" and ("); foreach (string key in segments) { strWhere.AppendFormat(" title like '%{0}%' or", key); } strWhere.Append(")"); keyword = string.Join(",", segments); } else { strWhere.AppendFormat(" and title like '%{0}%' or",keyword); } }
相关文档:https://www.cnblogs.com/anderslly/p/jiebanet.html