A colleague today showed me a problem he was having with full text search queries. All he was doing is including the ContentType managed property in the search query, which returned a Microsoft.Office.Server.Search.Query.InvalidPropertyException.
The reason for this is that the Content Type field is now marked as non-retrievable. The ManagedProperty class has a “Retrievable” property, which according to this MSDN article, specifies whether it can be used in queries: microsoft.office.server.search.administration.managedproperty.retrievable.aspx
According to this blog post, it used to be retrievable in SharePoint 2007. Definitely a gotcha – most people would think this is possible, and most may also sell it in a client meeting.
The problem is that you cant set it to true… I currently have no solution for this, but I thought I might post a list of ALL managed properties (in a default installation with very few content) that have Retrievable set as False.
PowerShell script to check properties:
Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication “Search Service Application” | where {$_.Retrievable -eq $false}
Results:
Account
BestBetKeywords
CategoryNavigationUrl
Colleagues
ContentsHidden
ContentSource
ContentType
DocComments
DocKeywords
DocSignature
DocSubject
EndDate
ExcludeFromSummary
ExpirationTime
FollowAllAnchor
HostingPartition
ModifiedBy
NLCodePage
Notes
OWS_URL
PrivateColleagues
Purpose
RankingWeightHigh
RankingWeightLow
RankingWeightName
SiteID
SocialTagTextUrl
SPSiteURL
StartDate
UrlDepth
WikiCategory
OK so I looked into it further, I tried setting it in the Search SA to be included in all results, but that didn’t work:
And adding it in the advanced search web part also doesn’t work:
The query will return no results. Trying to set the property to True in PowerShell or the OM still gives the same error.
So, the only workable solution that is flying around is the one posted on the MSDN forums. It still, however, is a workaround that can’t be used in ALL situations out there. This is not great, as one would think the ContentType field is something you would want to include in your search results.
Please let me know if you find any other solutions.