---
schema_version: "1"
id: af846359df108da95ca825b722251e0bf95048cce2bb22e793a76b81359b6ec3
title: FIND {SearchQuery}
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-find.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl-find.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0fd5c9ae1281c047b9d16aef7eb73157a42023503d41df579194ff87cce8c985
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# FIND {SearchQuery}

Use the required `FIND` clause of a SOSL query to specify the word or phrase to search for. A search query includes the literal word or phrase and can also include wildcards and logical operators (AND, OR, and AND NOT).

A search query includes:

- The literal text (single word or a phrase) to search for
- Optionally, wildcards
- Optionally, logical operators, including grouping parentheses

Searches are evaluated from left to right and use Unicode (UTF-8) encoding. Text searches are case-insensitive. For example, searches for Customer, customer, and CUSTOMER return the same results.

You can’t enter special types of text expressions (such as macros, functions, or regular expressions) that are evaluated at run time in the `FIND` clause.

**note:** Surround the `SearchQuery` with curly brackets to distinguish the search expression from other clauses in the text search.

## Search Terms

A `SearchQuery` can contain:

- Single words, such as `test` or `hello`
- Phrases that include words and spaces surrounded by double quotes, such as `"john smith"`

The search engine splits record information separated by spaces or punctuation into separate tokens. The search engine returns accurate search results from searches in East Asian languages that don't include spaces between words using morphological tokenization.

## Example

Consider the problem of indexing the term “Tokyo Prefecture” and a subsequent search for `Kyoto` in Japanese.

| Index                   | Search     |
| ----------------------- | ---------- |
| 東京都 Tokyo Prefecture | 京都 Kyoto |

Morphological tokenization segments the term 東京都 (Tokyo Prefecture) into two tokens.

|            |               |
| ---------- | ------------- |
| 東京 Tokyo | 都 Prefecture |

This form of tokenization ensures that a search for 京都 (Kyoto) returns only results that include 京都 (Kyoto) and not 東京都 (Tokyo Prefecture).

## Wildcards

You can specify the following wildcard characters to match text patterns in your search:

| Wildcard | Description                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \*       | Asterisks match zero or more characters at the middle or end of your search term. For example, a search for *john** finds items that start with *john*, such as, *john*, *johnson*, or *johnny*. A search for *mi\* meyers* finds items with *mike meyers* or *michael meyers*. If you are searching for a literal asterisk in a word or phrase, then escape the asterisk (precede it with the `\` character). |
| ?        | Question marks match only one character in the middle or end of your search term. For example, a search for _jo?n_ finds items with the term _john_ or _joan_ but not _jon_ or _johan_. You can't use a ? in a lookup search.                                                                                                                                                                                     |

When using wildcards, consider the following notes:

- The more focused your wildcard search, the faster the search results are returned, and the more likely the results will reflect your intention. For example, to search for all occurrences of the word `prospect` (or `prospects`, the plural form), it is more efficient to specify `prospect*` in the search string than to specify a less restrictive wildcard search (such as `prosp*`) that could return extraneous matches (such as `prosperity`).
- Tailor your searches to find all variations of a word. For example, to find `property` and `properties`, you would specify `propert*`.
- Punctuation is indexed. To find `*` or `?` inside a phrase, you must enclose your search string in quotation marks and you must escape the special character. For example, `"where are you\?"` finds the phrase `where are you?`. The escape character (`\`) is required in order for this search to work correctly.

## Operators

Combine multiple words with logic and grouping by using operators to form a more complex query. You can use the following special operators to focus your text search. Operator support is case-insensitive.

| Operator  | Description                                                                                                                                                                                                                                                                                                                                                               |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `" "`     | Use quotation marks around search terms to find matches in the order you entered your search terms. A search for `"monday meeting"` finds items that contain `monday meeting` in that order. To include the words “and,” “or,” and “and not” in your search results, surround those words in double quotes. Otherwise they’re interpreted as the corresponding operators. |
| `AND`     | Finds items that match all the search terms. For example, `john AND smith` finds items with both the word `john` and the word `smith`. Usually if an operator isn't specified, `AND` is the default operator. When searching articles, documents, and solutions, `AND` must be specified because `OR` is the default operator.                                            |
| `OR`      | Finds items with at least one of the search terms. For example, `john OR smith` finds items with either `john` or `smith`, or both words.                                                                                                                                                                                                                                 |
| `AND NOT` | Finds items that do not contain the search term. For example, `john AND NOT smith` finds items that have the word `john` but not the word `smith`.                                                                                                                                                                                                                        |
| ( )       | Use parentheses around search terms with logical operators to group search terms. For example, `("Bob" and "Jones") OR ("Sally" and "Smith")` searches for either Bob Jones or Sally Smith, and `("Bob") and ("Jones" OR "Thomas") and Sally Smith` searches for documents that contain Bob Jones and Sally Smith or Bob Thomas and Sally Smith.                          |

## `SearchQuery` Character Limits

If the `SearchQuery` string is longer than 10,000 characters, no result rows are returned. If `SearchQuery` is longer than 4,000 characters, any logical operators are removed. For example, the `AND` operator in a statement with a `SearchQuery` that’s 4,001 characters defaults to the `OR` operator, which could return more results than expected.

When you combine multiple operators in a search string, they're evaluated in this order:

1.  Parentheses
2.  AND and AND NOT (evaluated from right to left)
3.  OR

## Reserved Characters

The following characters are reserved:

```soql
? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -
```

Reserved characters, if specified in a text search, must be escaped (preceded by the backslash \\ character) to be properly interpreted. An error occurs if you do not precede reserved characters with a backslash. This is true even if the `SearchQuery` is enclosed in double quotes.

For example, to search for the following text:

```soql
{1+1}:2
```

insert a backslash before each reserved character:

```soql
\{1\+1\}\:2
```

## Example FIND Clauses

| Type of Search                                  | Examples                                          |
| ----------------------------------------------- | ------------------------------------------------- |
| Single term examples                            | `FIND {MyProspect}`                               |
| Single phrase                                   | `FIND {John Smith}`                               |
| Term OR Term                                    | `FIND {MyProspect OR MyCompany}`                  |
| Term AND Term                                   | `FIND {MyProspect AND MyCompany}`                 |
| Term AND Phrase                                 | `FIND {MyProspect AND "John Smith"}`              |
| Term OR Phrase                                  | `FIND {MyProspect OR "John Smith"}`               |
| Complex query using AND/OR                      | `FIND {MyProspect AND "John Smith" OR MyCompany}` |
| Complex query using AND NOT                     | `FIND {MyProspect AND NOT MyCompany}`             |
| Wildcard search                                 | `FIND {My*}`                                      |
| Escape sequences                                | `FIND {Why not\?}`                                |
| Invalid or incomplete phrase (will not succeed) | `FIND {"John Smith}`                              |

Additional single term examples:

```soql
FIND {mylogin@mycompany.com}
```

```soql
FIND {FIND}
```

```soql
FIND {IN}
```

```soql
FIND {RETURNING}
```

```soql
FIND {LIMIT}
```

Additional complex query using AND/OR:

```soql
FIND {MyProspect AND ("John Smith" OR
MyCompany)}
```

## FIND Clauses in Apex

The syntax of the `FIND` clause in Apex differs from the syntax of the `FIND` clause in SOAP API and REST API:

- In Apex, the value of the `FIND` clause is demarcated with single quotes. For example:

  ```apex
  FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead
  ```

  Apex that is running in system mode ignores field-level security while scanning for a match using `IN ALL FIELDS`.

- In the API, the value of the `FIND` clause is demarcated with braces. For example:

  ```apex
  FIND {map*} IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead
  ```

The _Apex Developer Guide_ has more information about using [SOSL and SOQL with Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL.htm).
