6

I'm working with SP2013 Search and I need to create crawled properties by PowerShell script. I found out that I can use New-SPEnterpriseSearchMetadataCrawledProperty function, but I have not found what is -PropSet property.

$crPropery = New-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchApp -Category  $searchCategory -PropSet $propSetId -Name $crPropertyName -VariantType $variantType -IsNameEnum $false

I know that SharePoint Search by default uses these PropSetIds:

  • 158d7563-aeff-4dbf-bf16-4a1445f0366c - TaxonomyField
  • fea84df6-a0fc-492c-9aa7-d28b8dcb08b3 - SPFieldMultiLineText, HtmlField, ImageField, LinkField
  • ed280121-b677-4e2a-8fbc-0d9e2325b0a2 - SPFieldText, SPFieldChoice, SPFieldMultiChoice, SPFieldNumber, SPFieldCurrency, SPFieldDateTime, SPFieldBoolean, SPFieldUser, SPFieldUrl, SPFieldGuid
  • 00130329-0000-0130-c000-000000131346 - other field types

What is PropSet? What actions SharePoint does depend on it? Should I use PropSet depends on field type?

In additional, by default SharePoint creates two crawled property for some field types, for example, if you have field "sp test" of SPFieldText type, Sharepoint creates

  1. sptestOWSTEXT - management property
  2. ows_q_TEXT_sptest - crawled property which is mapped to sptestOWSTEXT, has ed280121-b677-4e2a-8fbc-0d9e2325b0a2 propSetId and unchecked Include in full-text index
  3. ows_sp_x0020_test - crawled property which is not mapped to any management property, has 00130329-0000-0130-c000-000000131346 propSetId and checked Include in full-text index

Could you explain for what purpose SharePoint creates ows_sp_x0020_test crawled property?

  • Sorry can't help but your question helped explain something for me. Thanks. – Swanny Nov 29 '13 at 4:50
4

Based on crawled property the crawler creates additional crawled properties.

For example if you create a publishing HTML field, the 'normal' crawled property only contains the text that is in the HTML field (without the HTML markup).

The crawler creates additional crawled properties to be able to get to the complete HTML. The property with a ows_r_HTML_ prefix will include the HTML, but only if you specify the correct SourceId in your field definition.

More info: http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9ea5648f-e8af-4deb-9e1a-99af07c3142d/publishing-html-field-and-crawled-properties?forum=sharepointdevelopment

7

In SharePoint 2013 is PropSet related to SPFieldType. If you create your property with GUID 00130329-0000-0130-c000-000000131346 SharePoint will create new property with same name and correct GUID.

158d7563-aeff-4dbf-bf16-4a1445f0366c - TaxonomyField

fea84df6-a0fc-492c-9aa7-d28b8dcb08b3 - SPFieldMultiLineText, HtmlField, ImageField, LinkField

ed280121-b677-4e2a-8fbc-0d9e2325b0a2 - SPFieldText, SPFieldChoice, SPFieldMultiChoice, SPFieldNumber, SPFieldCurrency, SPFieldDateTime, SPFieldBoolean, SPFieldUser, SPFieldUrl, SPFieldGuid

00130329-0000-0130-c000-000000131346 - other field types

Here you have correct crawled property names https://technet.microsoft.com/en-us/library/jj613136.aspx

Here is PowerShell script for creating Crawled Properties:

function EnsureCrawledProperty([Microsoft.SharePoint.SPField]$f, $sa)
{
    $CrawlPropName = ""
    $CrawlPropSet = ""
    $PropSetTax = "158d7563-aeff-4dbf-bf16-4a1445f0366c" # - TaxonomyField
    $PropSetMulti = "fea84df6-a0fc-492c-9aa7-d28b8dcb08b3" # - SPFieldMultiLineText, HtmlField, ImageField, LinkField
    $PropSetSingle = "ed280121-b677-4e2a-8fbc-0d9e2325b0a2" # - SPFieldText, SPFieldChoice, SPFieldMultiChoice, SPFieldNumber, SPFieldCurrency, SPFieldDateTime, SPFieldBoolean, SPFieldUser, SPFieldUrl, SPFieldGuid
    $PropSetOther = "00130329-0000-0130-c000-000000131346" # - other field types

    Switch ($f.Type)
    {
        # propset multi
        $([Microsoft.SharePoint.SPFieldType]::Note)         { $CrawlPropName = "ows_r_MTXT_$($f.InternalName)"; $CrawlPropSet = $PropSetMulti }
        # propset single
        $([Microsoft.SharePoint.SPFieldType]::Text)         { $CrawlPropName = "ows_q_TEXT_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::Choice)       { $CrawlPropName = "ows_q_CHCS_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::MultiChoice)  { $CrawlPropName = "ows_q_CHCM_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::Number)       { $CrawlPropName = "ows_q_NMBR_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::Currency)     { $CrawlPropName = "ows_q_CURR_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::DateTime)     { $CrawlPropName = "ows_q_DATE_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::Boolean)      { $CrawlPropName = "ows_q_BOOL_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::User)         { $CrawlPropName = "ows_q_USER_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }
        $([Microsoft.SharePoint.SPFieldType]::URL)          { $CrawlPropName = "ows_q_URLH_$($f.InternalName)"; $CrawlPropSet = $PropSetSingle }

        default {

            if($f -is [Microsoft.SharePoint.Taxonomy.TaxonomyField])
            {
                $CrawlPropName = "ows_taxId_$($f.InternalName)"; $CrawlPropSet =  $PropSetTax
            }
            else
            {
                Write-Warning "Unknown type $($f.Type)"
            }

        }

    }

    $existingProp = Get-SPEnterpriseSearchMetadataCrawledProperty -Name $CrawlPropName -SearchApplication $sa

    if($existingProp -eq $null)
    {
        Write-Output "Creating crawled property $CrawlPropName for $($f.InternalName)"
        New-SPEnterpriseSearchMetadataCrawledProperty -Category SharePoint -IsNameEnum $false -Name $CrawlPropName -PropSet $CrawlPropSet -SearchApplication $sa -VariantType 0 | Out-Null
    }
    else
    {
        Write-Output "Crawled property $CrawlPropName for $($f.InternalName) already exists"
    }
}
0

The PropSet of a crawled property isn't related to the field type but to the category.

When you look at the crawled properties in the UI you'll see that they are grouped in categories like SharePoint, Business Data, Web, Office, etc. These categories represent the source "type" of the crawled property.

For instance, when you define a custom field in a list, like your field "sp test", SharePoint will automatically pick this field up when it's crawling your content and it will turn it into a crawled property in the SharePoint category. Would you be crawling an external, non SharePoint, website, SharePoint will automatically create crawled properties for all the -tags in the crawled HTML and those crawled properties will show up in the Web category. This goes for other categories too: Business Data shows crawled properties retrieved from BCS-sources, Office shows crawled properties retrieved from Office document properties like the title or author of a document. The PropSet is merely the (GU)ID of the Category.

The ows_sp_x0020_test crawled property in your question is what I stated before: a "regular" crawled property that SharePoint picks up when crawling your SharePoint content. It puts the property in category SharePoint which has PropSet 00130329-0000-0130-c000-000000131346. I'm not entirely sure why the ows_q_TEXT_sptest property gets created though, but I guess that's a SharePoint 2013 specific thing...

~Mark

  • It is 2010 specific thing... – Jan Novák Sep 6 '15 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.