Radi Atanassov

SharePoint MCM, MVP, MCT and owner of OneBit Software

SharePoint 2010 Search: Some Managed Properties cannot be included in queries

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:

image

clip_image001

And adding it in the advanced search web part also doesn’t work:

clip_image001[6]

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.

Comments (4) -

  • Marek Czarzbon

    11/24/2010 8:45:31 AM | Reply

    Nice!
    But what about 'contenttype:<mycontenttype>' directly in the search field, which you can use also in code behind.

    Marek

  • Marek Czarzbon

    11/24/2010 8:57:34 AM | Reply

    This is even more interesting! If you use 'contenttype:document' or 'contenttype:event' from the default.aspx site in the Search Center it work fine! But not if you resend the same query in the result.aspx site!

    If you go to the webpart setting and save the query as 'fix query" it works with contentType, too.

    I have ti investigate, where the difference is.

  • Ради Атанасов

    11/24/2010 10:19:53 PM | Reply

    Hey Marek,

    Thanks for your comments, fellow MCM candidate! Your findings are awesome and definitely call for some further investigation. I will also look into this deeper, but let me know if you find out more info.

    Maybe check the logs for the actual query that gets through (it will appear in ULS).

    See you soon!

  • reuma

    1/18/2011 4:24:29 AM | Reply

    I encountered the same problem.
    To solve it i add new managed property to contentType and then i can use this new property at search WP.

Pingbacks and trackbacks (1)+

Add comment

Loading