Using “Append Text to Query” in Search Core Results

May 26, 2012

After creating a document library with uniquely named columns, populating the columns with values, and waiting for Search to crawl the library, you set up a Display Group and Scope on the Site Collection Administration Search scopes management page (_layouts/viewscopes.aspx), then add a Search Box and Search Core Results web part to a page and configure them to use your new group and scope. The library documents are displayed, but hmmm… so are the library views and folders.

Naturally, SharePoint Search indexes and returns as much as it can, and it depends on you to filter out what you don’t want. If you can’t filter the results using Scope rules, then one alternative is to use the Search Core Results web part -> Search Core Results Action Links -> Results Query Options -> Append Text to Query field. You could simply add…

isDocument=Yes or IsDocument:1

… to filter out the folders. The difference between the “=” and “:” property operator is spelled out in this MSDN Property Restriction Keyword Queries article.

But, what if your library has a Link to a Document content type that refers to ASPX pages rather than DOC’s or PDF’s? This is where an understanding of the default metadata properties might come in handy. The Search Core Results web part Display Properties -> Fetched Properties lists the default metadata properties used by Search. See this Change how search results appear in the Search Core Results Web Part (Search Server 2010) Technet article for more details.

<root xmlns:xsi="">
    <Column Name="WorkId" />
    <Column Name="Rank" />
    <Column Name="Title" />
    <Column Name="Author" />
    <Column Name="Size" />
    <Column Name="Path" />
    <Column Name="Description" />
    <Column Name="Write" />
    <Column Name="SiteName" />
    <Column Name="CollapsingStatus" />
    <Column Name="HitHighlightedSummary" />
    <Column Name="HitHighlightedProperties" />
    <Column Name="ContentClass" />
    <Column Name="IsDocument"/>
    <Column Name="PictureThumbnailURL"/>
    <Column Name="PopularSocialTags"/>
    <Column Name="PictureWidth"/>
    <Column Name="PictureHeight"/>
    <Column Name="DatePictureTaken"/>
    <Column Name="ServerRedirectedURL"/>

The trick here is to use ContentClass in the Append Text to Query field instead of IsDocument, as in …


Combining multiple items in the Append Text to Query field can be accomplished with a space between each , like …

contentclass:STS_ListItem_DocumentLibrary Size<300000

… which will filter results to list items with a size property of less than 300KB.

To make library column available in the Search Core Results window, map it as a Managed Property in Search and then add it among the other Column Names in the Fetched Properties XML. For example, would fetch values from a crawled library column created with the ungainly name of “PHSPMGDocumentStatus” that let everyone know where it came from and let the System Administrators identify it uniquely among the other crawled Status columns in the system. Once mapped and crawled, you can filter on this column in the search scope or add it to the Append Text to Query field.

What’s more:

One Reply to “Using “Append Text to Query” in Search Core Results”

Leave a Reply

Your email address will not be published. Required fields are marked *