Kloudless Blog

Kloudless Unified APIs enable you to code once and integrate many

The Salesforce API offers two options for searching for records within Salesforce: SOQL, (Salesforce Object Query Language and SOSL) and SOSL (Salesforce Object Search Language) which are available in Salesforce’s REST API.

How do the two differ? Well, SOQL functions as their version of the SQL SELECT statement for Salesforce Objects (sObjects) and is utilized in their /query endpoint. SOSL on the other hand, has a more flexible syntax and can also be used as a simple keyword search. We’ll be focusing on the latter in this post.

Let’s start by taking a look at the search request:

Pretty straightforward. XX.X is the Salesforce API version, and the q parameter takes search_string as an argument.

So with the search query q=FIND {test} in ALL FIELDS, we might get the results:

As you can see in the search results, the basic information you’d get would only include type and url. You can also see that there are multiple types of sObjects returned in the results. This is one of the advantages of SOSL has over SOQL, as queries will be conducted over multiple object types across the Salesforce database.

However, this advantage can also be a flaw, as a search this wide is bound to be more resource intensive and therefore is limited.

It’s possible that the information you’re looking for won’t be returned as the information you’re looking for might not be included as the SOSL query hits a data limit before the filtering even takes place. It’s possible records of certain object types won’t even make it into the search results. In the example above, there are no ContentDocument and Document sObject records at all.

Another inconvenience is the having only id and basic object attributes (type, url) as the return result. It’s a little harder to make sense out of the search results without making additional queries or pulling for extra record metadata.

To remedy this, we can simply be more specific with our search results. If we refine our SOSL query with the following:


By specifying what field to search in, what sObject types and what additional fields we’d like returned we can not only improve our search accuracy, but also get additional metadata that makes our search results more useful.

Returned data:

At least now we can see what the name or titles of our documents are!

Searching via SOSL is by no means perfect; however, it is still a very useful function that Kloudless supports within our Salesforce integration. I’ve included how to perform searches with SOSL using our Kloudless platform below:


By setting the lang parameter to SOSL, and the q parameter to the SOSL query, you can query Salesforce with SOSL through the Kloudless CRM search endpoint.

Returned Data:

The lang parameter can also be set to SOQL for a SOQL query, or if left unset, a keyword search as well. For more information on our CRM search, feel free to check out our Kloudless CRM API Docs.

More details on how to specify SOSL syntax can be found in the Salesforce Developer Documentation. You can also test out SOSL queries using the Salesforce Developer Workbench.



Share this article:

Let’s get started. Start building for free today.