KeywordQuery and ResultTable
-
Monday, April 16, 2012 3:11 PM
Hello All,
KeywordQuery keywordQuery = new KeywordQuery(searchProxy);
I have written a KeywordQuery to get search results. I can see so many fields in the ResultTable, But how I can get the DateCreated or any other property of the result Item ?
keywordQuery.QueryText = myQueryText.ToString();
keywordQuery.ResultsProvider = SearchProvider.Default;
keywordQuery.ResultTypes = ResultType.RelevantResults;
ResultTableCollection resultsTableCollection = keywordQuery.Execute();
ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];
DataTable resultsDataTable = new DataTable();
resultsDataTable.TableName = "Results";
resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);
int rowCount = searchResultsTable.RowCount;
List<MonthEvent> results = new List<MonthEvent>();
MonthEvent myMonthEvent;
DataRow resultRow;
for (int i = 0; i < rowCount; i++)
{
resultRow = resultsDataTable.Rows[i];
myEvent = new MonthEvent();
myEvent .Day = 1;
myEvent .Header = resultRow["Title"].ToString();
myEvent .Url = resultRow["Path"].ToString();
myEvent .Content = resultRow["Title"].ToString();
// myEvent.Date = resultRow["DateCreated"].ToString(); == How I can get this ?
results.Add(myMonthEvent);
}Parakram
All Replies
-
Monday, April 16, 2012 7:53 PM
To return certain managed properties in your results you must use the KeywordQuery.SelectProperties property. You can use the AddRange method to add an array of managed property string names or just Add to add one. KeywordQuery.SelectProperties.Add("DateCreated").
Blog | SharePoint Field Notes Dev Tool | ClassMaster
- Marked As Answer by Shailendra Singh ChauhanMicrosoft Employee Tuesday, April 17, 2012 8:37 AM
-
Tuesday, April 17, 2012 8:38 AMHello Steve,
Thanks for your help. It worked like a charm :)Parakram

