Monthly Archives: November 2011

Exclude Asset Library from search results by modifying search scopes

It’s possible to exclude SharePoint Lists from search results by excluding their types in the search scope definition.

Therefore you need to define an search scope rule based on a “property”. You have to use “contentclass” and a value.

There are much lists of the possible values out in the web.

Here is mine 🙂

Value Description
STS_Web Site
STS_List Custom List
STS_ListItem Custom List item
STS_List_DocumentLibrary Document Library
STS_ListItem_DocumentLibrary Document Libary item
STS_List_Links Link List
STS_ListItem_Links Link List item
STS_List_Events Event List
STS_ListItem_Events Event List item
STS_List_Tasks Task List
STS_ListItem_Tasks Task List item
STS_List_Contacts Contact List
STS_ListItem_Contacts Contact List item
STS_List_Announcements Announcements List
STS_ListItem_Announcements Announcements List item
STS_List_DiscussionBoard Discussion Board
STS_ListItem_DiscussionBoard Discussion Board item
STS_List_GanttTasks Gantt Task List
STS_ListItem_GanttTasks Gantt Task item
STS_List_IssueTracking Issue Tracking list
STS_ListItem_IssueTracking Issue Tracking item
STS_List_Survey Survey
STS_ListItem_Survey Survey item
STS_List_PictureLibrary Picture Library
STS_ListItem_PictureLibrary Picture Library Item
STS_List_WebPageLibrary Web Page Library
STS_ListItem_WebPageLibrary Web Page Library Item
STS_List_XMLForm (InfoPath) Form Library
STS_ListItem_XMLForm (InfoPath) Form Library item
STS_List_850 Page Library
STS_ListItem_850 Page Library item
urn:content-class:SPSSearchQuery Search Query
urn:content-class:SPSListing:News News Listing
urn:content-class:SPSPeople People
urn:content-classes:SPSCategory Category
urn:content-classes:SPSListing Listing
urn:content-classes:SPSPersonListing Person Listing
urn:content-classes:SPSTextListing Text Listing
urn:content-classes:SPSSiteListing Site Listing
urn:content-classes:SPSSiteRegistry Site Registry Listing

 

You can generally exclude list items from search by using the value “STS_ListItem_PictureLibrary” for the property “contentclass”.

But how to exclude items or lists of type “Asset Library” which is also a standard list template like “Document Library”, “Picture Library”, “Calendar List”, … and “Page Library” which has as code (850) as name. (Marked red in the list above.)

I checked the 14 hive and figured out the 850 is the list template ID of “Page Library”. And the list template ID of “Asset Library” is 851.

So I used the following query in the search box: “(scope:"All Websites") (contentclass:STS_List_851)

I created a new search scope exclude rule on the site collection using “STS_List_851” in it worked! Now there are no more Asset Libary links in the search result. If you you “STS_ListItem_851” you can exclude Asset Library Litems.

(No screenshots today, sorry!)

PowerShell Script for Recreating the Server Cache (related to error in Windows Event Log, Event ID 6482: Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance)

Today I’ve had the error:

Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (150CA1DD-02E3-47C0-AA55-005A2927751F).

Reason: An update conflict has occurred, and you must re-try this action. The object SearchDataAccessServiceInstance was updated by DOMAINspfarm, in the OWSTIMER (5040) process, on machine sps2010. 
View the tracing log for more information about the conflict.

Technical Support Details:
Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException: An update conflict has occurred, and you must re-try this action.
The object SearchDataAccessServiceInstance was updated by domainuser, in the OWSTIMER (5040) process, on machine (server name). 
View the tracing log for more information about the conflict.
   at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
   at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)

 

There is a nice article on Jeff DeVerter’s blog:

Jeff references to this articles:

I had to clean up lots of servers. Because of that I’ve created a little PowerShell script.

The script will automatically process all steps descripted by the KB article, Chaitu Madala and Jeff.

You can execute the script on every server.

If your receive a yellow message at the end of the process that the resulting “cache.ini” file is diffrent from the original one. I think the cache.ini file contains a timestamp and it is OK if the new timestamp value is greater than the original one… But you use the script at your own rist – as always.

 

SCRIPT:

# Script created by Ingo Karstein (https://blog.kenaro.com)
Write-Host "Script created by Ingo Karstein (https://blog.kenaro.com)" -ForegroundColor DarkGreen

$cacheFolderRoot = Join-Path ${env:ProgramData} "MicrosoftSharePointConfig"
$cacheFileCopy = Join-Path ${env:temp} "cacheFileTmp.ini.ik"

Write-Host "" -ForegroundColor DarkBlue
Write-Host "Starting" -ForegroundColor DarkBlue

if( Test-Path $cacheFileCopy -PathType Leaf) {
    write-host "Cache File copy lopcation does already exist. Please remove it: $($cacheFileCopy)" -ForegroundColor Red
    return
}

Write-Host "Looking for cache folder" -ForegroundColor DarkBlue
$cacheFolder =  @(GEt-ChildItem -Path $cacheFolderRoot | ? {Test-Path $_.FullName -PathType Container} | ? {Test-Path -Path (Join-Path $_.FullName "cache.ini") -PathType Leaf})

if( $cacheFolder -ne $null -and $cacheFolder.Count -eq 1) {
    $cacheFolder0 = $cacheFolder[0].FullName
    Write-Host "Cache folder found: $($cacheFolder0)" -ForegroundColor DarkBlue
    $cacheFile = join-path $cacheFolder0 "cache.ini"
    Write-Host "Cache ini file: $($cacheFile)" -ForegroundColor DarkBlue

    Write-Host "Stop SharePoint timer service" -ForegroundColor DarkBlue
    stop-service sptimerv4

    Write-Host "Copy cache.ini to it's temp location ($($cacheFileCopy))" -ForegroundColor DarkBlue
    copy-item -path $cacheFile -Destination $cacheFileCopy -force

    Write-Host "Set the content of cache.ini to ""1""" -ForegroundColor DarkBlue
    "1" | set-content $cacheFile -encoding ascii -force

    Write-Host "Remove all .XML files from the cache folder" -ForegroundColor DarkBlue
    get-childitem $cacheFolder0 -filter "*.xml" | remove-item -force -confirm:$false

    Write-Host "Start SharePoint timer service" -ForegroundColor DarkBlue
    start-service sptimerv4

    $xmlFound = -1
    $xmlFoundLast = -1
    $eqCount = 0

    Write-Host "Now the cache will be recreated... Waiting... This will take a minute or so..." -ForegroundColor DarkBlue
    write-host "(every second a dot will appear on the end of the next line)" -ForegroundColor gray
    do {
        write-host "." -nonewline -ForegroundColor Magenta
        start-sleep -second 1
        $xmlFoundLast = $xmlFound
        $xmlFound = (@(get-childitem $cacheFolder0 -filter "*.xml")).Count
        if( $xmlFound -eq $xmlFoundLast ) {
            $eqCount++
        } else {
            $eqCount = 0
        }
    } while ($eqCount -lt 30)
    
    Write-Host ""
    Write-Host "Done" -ForegroundColor DarkBlue

    $a = get-content $cacheFileCopy
    $b = get-content $cacheFile

    if( $a -ne $b ) {
        if( [int]$a -gt [int]$b ) {
            write-host "An error occured. the content of the cache file is not identically to it's value before processing." -ForegroundColor Red
            write-host "Old: $($a)"
            write-host "New: $($b)"    
        } else {
            write-host "MAYBE an error occured. the content of the cache file is not identically to it's value before processing." -ForegroundColor DarkYellow
            write-host "Old: $($a)"
            write-host "New: $($b)"    
        }
    } else {
        write-host "Processing finished successfully! You need to execute the  script on every server!!" -foregroundcolor darkgreen
        remove-item $cacheFileCopy -Force -confirm:$false
    }
} else {
    write-host "Could not find the cache folder or found too much cache folders!" -foregroundcolor red
}