Salesforce Developer Search

salesforce-developer

https://trailhead.salesforce.com/force_com_dev_beginner/search_solution_basics/search_solution_basics_choosing
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_search.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_search_suggest_records.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_search_suggest_title_matches.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_search_suggest_queries.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_search_parameterized.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_query.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api.meta/api/sforce_api_calls_search.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api.meta/api/sforce_api_calls_query.htm
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_rest.meta/api_rest/resources_sobject_suggest_articles.htm
https://help.salesforce.com/apex/HTViewHelpDoc?id=promoted_search_terms.htm&language=en_US
https://developer.salesforce.com/docs/atlas.en-us.204.0.api_meta.meta/api_meta/meta_synonymdictionary.htm

// Salesforce - Developer - Search:

Beside SOQL and SOSL, there is also another API for searching.  Meet suggested 
records API. Perhaps you might already know suggested records by its aliases: 
auto-suggestion, instant results, type-ahead.

Search Suggested Records and Search Suggested Articles REST methods are 
available for you to use.

1. Query (REST) and query() (SOAP)—Executes a SOQL query against the specified 
   object and returns data that matches the specified criteria.

2. Search (REST) and search() (SOAP)—Executes a SOSL text string search against 
   your org’s data.

If you’d rather not use SOSL or SOQL, consider Parameterized Search in REST. 
Instead of a search string in the URL, you use parameters (hence the name) in 
the URL.

As for Apex, you can use SOQL or SOSL on the fly by surrounding the statement 
in square brackets. You can also use a Search Class to perform dynamic SOSL 
queries and a Search Namespace for getting search results and suggestion results.

1. Limit which data you’re searching through
2. Limit which data you’re returning

To limit which data is searched, use IN SearchGroup. You can search for name, 
email, phone, sidebar, or all fields. For example, if you want to search only 
for an email, you search through only email fields:

FIND {jsmith@cloudkicks.com} IN EMAIL FIELDS RETURNING Contact

Think about how you could limit the results or at least break them up into 
smaller, easier-to-digest chunks.

We can use RETURNING FieldSpec to specify which data is returned. We used it 
in the last unit, but let’s talk about the more advanced  elements it includes.

1. ObjectTypeName—Specifies the object to return.
2. FieldList—Specifies the fields to return.
3. ORDER By—Specifies which fields to order the results by. You can also 
   specify ascending or descending order.
4. LIMIT n—Sets the maximum number of records returned for the given object.
5. OFFSET n—Sets the starting row offset into the result set returned by your 
   query.

FIND {Cloud Kicks} RETURNING Account (Name, Industry 
  ORDER BY Name 
  LIMIT 10 
  OFFSET 25)

The WITH statements, which filter records by certain predefined fields. By 
prefiltering results, you return fewer results and improve performance.

FIND {Cloud Kicks} RETURNING Account (Name, Industry)
    WITH DIVISION = 'Global'

FIND {race} RETURNING KnowledgeArticleVersion
    (Id, Title WHERE PublishStatus='online' and language='en_US')
    WITH DATA CATEGORY Location__c AT America__c

FIND {first place} 
  RETURNING 
    User (Id, Name),
    FeedItem (
      id, ParentId WHERE CreatedDate = THIS_YEAR Order by CreatedDate DESC
    )
  WITH NETWORK = '00000000000001'

Find {shoe} RETURNING Product2 WITH PricebookId = '01sxx0000002MffAAE'

Search Suggested Records—Returns a list of suggested records whose names match 
the user’s search string. The suggestions resource provides a shortcut for users 
to navigate directly to likely relevant records, before performing a full search.

Search Suggested Article Title Matches—Returns a list of Salesforce Knowledge 
articles whose titles match the user’s search query string. Provides a shortcut 
to navigate directly to likely relevant articles before the user performs a 
search.

SObject Suggested Articles for Case—Returns a list of suggested Salesforce 
Knowledge articles for a case.

Let’s use the Search Suggested Article Title Matches option as an example of how 
suggestion works. Here’s the basic syntax, but check out the API docs for the 
full list of parameters available.

/vXX.X/search/suggestTitleMatches?q=search string&
  language=article language&
  publishStatus=article publication status

/vXX.X/search/suggestTitleMatches?q=race+tips&
  language=en_US&
  publishStatus=Online

To setup synonym groups, from Setup, enter Synonyms in the Quick Find box, then 
select Synonyms. Have tons of synonyms (9,586 to be exact) to import? Take 
advantage of the metadata API listed in the references section. Use Bulk Upload 
for the win.

The next step is promoted search terms for Knowledge articles.  Promoted search 
terms are useful for getting more eyeballs on an article that you know is 
commonly used to resolve a support issue. Getting it set up is simple. Admins 
find the perfect article and then add terms to the Promoted Search Terms related 
list. Users who enter those keywords see the chosen article at the top in search 
results.

For example, your support team has crafted the absolutely perfect article on 
how to return shoes that don’t fit. The admin goes in and updates that article 
to include promoted search terms of return and doesn’t fit. When users search 
for those terms, the article pops up.

A couple things to help your admin fine-tune promoted search terms:

1. The maximum number of characters per term is 100. For best results when 
   matching users’ search terms, limit each promoted term to a few keywords.

2. Don’t go overboard. For best results, use them selectively, which means 
   create a limited number of promoted terms and a limited number of promoted 
   articles per term. Adding too many promoted search terms could affect the 
   relevance ranking for users, leading to unwanted results. Your organization 
   can create a maximum of 2,000 promoted terms.

3. Article search matches a promoted term whenever all keywords within the term 
   occur within the user’s search terms, in any sequence. Each keyword must 
   match exactly.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License