---
schema_version: "1"
id: 3eebd0640f67bf680dafbe1030f50ed10d17ddd6aef2065c79bd5f969444defd
title: Salesforce Object Search Language (SOSL)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-sosl.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7c617e25c3657dae4f10c21ecdf381acf8d145c184d7e724925fc8870fdbc648
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# Salesforce Object Search Language (SOSL)

Use the Salesforce Object Search Language (SOSL) to construct text-based search queries against the search index.

When building efficient SOSL queries, create filters that are selective. Search analyzes all records in the index and by default, only the top 2,000 matched records are returned based on relevancy. This API supports pagination to fetch additional matches. Sharing is applied after the result set is returned from the search stack. If your filters aren’t selective and cause search term matches of more than 2000 records, there’s a possibility of running into search crowding.

You can search text, email, and phone fields for multiple objects, including custom objects, that you have access to in a single query in the following environments.

- SOAP API search() calls. See [search()](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_search.htm) in the _SOAP API Developer Guide_.
- REST API Search calls. See [Search](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search.htm) in the _REST API Developer Guide_.
- Apex statements. See [SOQL and SOSL Queries](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL.htm) in the _Apex Developer Guide_.
- Visualforce controllers and getter methods. See [Controller Methods](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_methods.htm) in the _Visualforce Developer Guide_.
- Schema Explorer of the Eclipse Toolkit. See [Schema Explorer](https://developer.salesforce.com/docs/atlas.en-us.eclipse.meta/eclipse/eclipse_schema_browser.htm) in the _Force.com IDE Developer Guide_.

**note:** If your org has relationship queries enabled, SOSL supports SOQL relationship queries.

## When to Use SOSL

Use SOSL when you don’t know which object or field the data resides in, and you want to:

- Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize multiple terms within a field and build a search index from this, SOSL searches are faster and can return more relevant results.
- Retrieve multiple objects and fields efficiently where the objects might or might not be related to one another.
- Retrieve data for a particular division in an organization using the divisions feature.
- Retrieve data that’s in Chinese, Japanese, Korean, or Thai. Morphological tokenization for CJKT terms helps ensure accurate results.

## Performance Considerations

If your searches are too general, they’re slow and return too many results. Use the following clauses to define efficient text searches.

- `IN`: Limits the types of fields to search, including email, name, or phone.
- `LIMIT`: Specifies the maximum number of rows to return.
- `OFFSET`: Displays the search results on multiple pages.
- `RETURNING`: Limits the objects and fields to return.
- `WITH DATA CATEGORY`: Specifies the data categories to return.
- `WITH DivisionFilter`: Specifies the division field to return.
- `WITH NETWORK`: Specifies the Experience Cloud site ID to return.
- `WITH PricebookId`: Specifies the price book ID to return.

## Navigating This Document

- To see a list of available resources, see [SOSL Syntax](https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl-syntax.md#sosl-syntax).
- To get started working with SOSL, see [Example Text Searches](https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl-examples.md#example-text-searches).
