本文整理汇总了C#中IndexQuery.Find方法的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery.Find方法的具体用法?C# IndexQuery.Find怎么用?C# IndexQuery.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexQuery
的用法示例。
在下文中一共展示了IndexQuery.Find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindContent
public SearchResultCollection FindContent(string queryText, IList<string> categoryNames, int pageIndex, int pageSize)
{
// Check queryText for invalid fields
if (queryText.Contains("viewroleid:"))
{
throw new SearchException("Don't try to mess with security!");
}
ICuyahogaContext cuyahogaContext = this._cuyahogaContextProvider.GetContext();
User currentUser = cuyahogaContext.CurrentUser;
IList<Role> roles;
if (currentUser != null)
{
roles = currentUser.Roles;
}
else
{
// Assume anonymous access, get all roles that have only anonymous access.
roles = this._userDao.GetAllRolesBySite(cuyahogaContext.CurrentSite).Where(role => role.IsAnonymousRole).ToList();
}
IList<int> roleIds = roles.Select(role => role.Id).ToList();
IndexQuery query = new IndexQuery(GetIndexDirectory());
try
{
return query.Find(queryText, categoryNames, pageIndex, pageSize, roleIds);
}
catch (ParseException ex)
{
Logger.Error(string.Format("Invalid query: {0}", queryText), ex);
throw new SearchException("Invalid search query", ex);
}
}