The optional WITH DATA CATEGORY clause allows you to filter all search results that are associated with one or more data categories and are visible to users. The WITH DATA CATEGORY clause can be used in API version 18.0 or later.
WITH DATA CATEGORY DataCategorySpec [logicalOperatorDataCategorySpec2 ... ]
Where DataCategorySpec consists of a groupName, Operator, and category.
| Name | Description |
|---|---|
| groupName | The name of the data category group to filter. For information on category groups, see “Creating and Modifying Category Groups” in the Salesforce online help. |
| Operator | Use one of the following operators:
|
| category | The name of the category to filter. To include multiple data categories, enclose them in parentheses, separated by commas. For information on categories, see “Adding Data Categories to Category Groups” in the Salesforce online help. |
You can add multiple data category specifiers by using logical operators.
A SOSL statement using the WITH DATA CATEGORY clause must also include a RETURNING ObjectTypeName clause, with a WHERE clause that filters on the PublishStatus field.
| Search Type | Example |
|---|---|
| Search all published (online)Salesforce Knowledge articles with a category from one category group. |
FIND {tourism} RETURNING KnowledgeArticleVersion
(Id, Title WHERE PublishStatus='online')
WITH DATA CATEGORY Location__c AT America__c
|
| Search online FAQ articles with categories from two category groups. |
FIND {tourism} RETURNING FAQ__kav
(Id, Title WHERE PublishStatus='online')
WITH DATA CATEGORY Geography__c ABOVE France__c
AND Product__c AT mobile_phones__c
|
| Search archived FAQ articles from one category group. |
FIND {tourism} RETURNING FAQ__kav
(Id, Title WHERE PublishStatus='archived')
WITH DATA CATEGORY Geography__c AT Iceland__c
|
| Search all draft Salesforce Knowledge articles from one category group. |
FIND {tourism} RETURNING KnowledgeArticleVersion
(Id, Title WHERE PublishStatus='draft')
WITH DATA CATEGORY Geography__c BELOW Europe__c
|
For information on the SOQL WITH DATA CATEGORY clause, see WITH DATA CATEGORYfilteringExpression.