我不知道,如果你可以輕鬆地訪問所有索引項目。這樣做的目的是什麼?
然而,你可以做的是做一個手動搜索,然後處理結果。也許這對你來說會更好。
要進行搜索,您可以使用這樣的事情:
var index = SearchIndexInfoProvider.GetSearchIndexInfo("indexName");
if (index != null)
{
SearchParameters parameters = new SearchParameters()
{
SearchFor = "Something",
SearchSort = "##SCORE##",
Path = "/%",
ClassNames = "",
CurrentCulture = "EN-US",
DefaultCulture = CultureHelper.EnglishCulture.IetfLanguageTag,
CombineWithDefaultCulture = false,
CheckPermissions = false,
SearchInAttachments = false,
User = (UserInfo)MembershipContext.AuthenticatedUser,
SearchIndexes = index.IndexName,
StartingPosition = 0,
DisplayResults = 100,
NumberOfProcessedResults = 100,
NumberOfResults = 0,
AttachmentWhere = String.Empty,
AttachmentOrderBy = String.Empty,
};
// Performs the search and saves the results into a DataSet
System.Data.DataSet results = SearchHelper.Search(parameters);
if (!DataHelper.DataSourceIsEmpty(results))
{
foreach (DataRow searchItem in results.Tables[0].Rows)
{
// do whatever you need with the search item
}
}
}
您還可以過濾返回結果的數量,你可以在SearchPatameters看到。
來源
2016-04-29 10:39:08
Enn
這是假設你正試圖通過Kentico獲取結果。 –