---
schema_version: "1"
id: 0e8941674513f731b4ca97f64f007ae904c96873e3dfff7029d2f85913ce330e
title: Promoted Search Terms
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_forcecom_promoted_search_terms.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_promoted_search_terms.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 17121f74987ec0969a11812167f046197d2c9e13e12fac44199a24376fd74696
description: Promoted search terms are useful for promoting a Salesforce Knowledge article that you know is commonly used to resolve a support issue when an end user’s search contains certain keywords. Users can promote an article in search results by associating keywords with the article in Apex (by using the SearchPromotionRule sObject) in addition to the Salesforce user interface.
---
# Promoted Search Terms

Promoted search terms are useful for promoting a Salesforce Knowledge article that you know is commonly used to resolve a support issue when an end user’s search contains certain keywords. Users can promote an article in search results by associating keywords with the article in Apex (by using the SearchPromotionRule sObject) in addition to the Salesforce user interface.

Articles must be in published status (with a PublishSatus field value of Online) for you to manage their promoted terms.

## Example

This code sample shows how to add a search promotion rule. This sample performs a query to get published articles of type MyArticle\_\_kav. Next, the sample creates a SearchPromotionRule sObject to promote articles that contain the word “Salesforce” and assigns the first returned article to it. Finally, the sample inserts this new sObject.

// Identify the article to promote in search results
List<MyArticle\_\_kav> articles = \[SELECT Id FROM MyArticle\_\_kav WHERE PublishStatus='Online' AND Language='en\_US' AND Id='Article Id' WITH USER\_MODE\];
// Define the promotion rule
SearchPromotionRule s = new SearchPromotionRule(
    Query='Salesforce',
    PromotedEntity=articles\[0\]);

// Save the new rule
insert as user s;

To perform DML operations on the SearchPromotionRule sObject, you must enable Salesforce Knowledge.