Pergunta

I have created a managed property TaskDueDate linked to ows_DueDate(Date and Time) which I would like to display in my search query results. However the query doesn't return any values for taskDueDate.

Any ideas how I can display my custom managed property? (It looks like the KeywordQuery has the SelectProperties.Add method to achieve this)

string currentUser = SPContext.Current.Web.CurrentUser.Name;
string searchQuery = "select title, path, priority, assignedto, TaskDueDate" +
              " from scope()" + "WHERE \"scope\"=\'All Tasks\'" + 
" and assignedto = '" + currentUser + "'";

FullTextSqlQuery query = new FullTextSqlQuery(SPContext.Current.Site);
query.ResultTypes = ResultType.RelevantResults;
query.QueryText = searchQuery;
ResultTableCollection results = query.Execute();
Foi útil?

Solução

You didn't mention it in your question so just to make sure...

Did you perform a Full Crawl of the content source AFTER you mapped the ows_DueDate crawled property to the TaskDueDate managed property?

Do you know for sure there is content with a value for the ows_DueDate crawled property?

SOLUTION:

The problem was due to teh fact that the FullTextQueriable parameter is by default set to false when you create custom search properties. After setting this parameter to 1 with PowerShell my FullTextSqlQuery returned the values for my custom search properties.

Set-SPEnterpriseSearchMetadataManagedproperty -Identity {you id of your custom property} -Searchapplication "Search Service Application" {In my case} -FullTextQueriable 1

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top