---
schema_version: "1"
id: 43f525d5ed6ba0fc5160c78eed0280732e8996825f2b23927af2df2fe742f3bc
title: Example Text Searches
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-examples.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl-examples.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: bc5ff62dabca3200b1b08139d2936c12542a6b9ecaa316d48235460ef496893f
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# Example Text Searches

The following are examples of text searches that use SOSL.

Look for `joe` anywhere in the system. Return the IDs of the records where `joe` is found.

```soql
FIND {joe}
```

Look for the name `Joe Smith` anywhere in the system, in a case-insensitive search. Return the IDs of the records where `Joe Smith` is found.

```soql
FIND {Joe Smith}
```

Look for the name `Joe Smith` in the name field of a lead, return the ID field of the records.

```soql
FIND {Joe Smith}
IN Name Fields
RETURNING lead

```

Look for the name `Joe Smith` in the name field of a lead and return the name and phone number.

```soql
FIND {Joe Smith}
IN Name Fields
RETURNING lead(name, phone)

```

Look for the name `Joe Smith` in the name field of a lead. Return the name and phone number of any matching record that was also created in the current fiscal quarter.

```soql
FIND {Joe Smith}
IN Name Fields
RETURNING lead (name, phone Where createddate = THIS_FISCAL_QUARTER)
```

Look for the name `Joe Smith` or `Joe Smythe` in the name field of a lead or contact and return the name and phone number. If a people record is called `Joe Smith` or `Joe Smythe`, that record isn’t returned.

```soql
FIND {"Joe Smith" OR "Joe Smythe"}
IN Name Fields
RETURNING lead(name, phone), contact(name, phone)

```

Wildcards:

```soql
FIND {Joe Sm*}
FIND {Joe Sm?th*}

```

Delimiting “and” and “or” as literals when used alone:

```soql
FIND {"and" or "or"}
FIND {"joe and mary"}
FIND {in}
FIND {returning}
FIND {find}

```

Escaping special characters & | ! ( ) { } [ ] ^ " ~ \* ? : \\ ' + -

```soql
FIND {right brace \}}
FIND {asterisk \*}
FIND {question \?}
FIND {single quote  \'}
FIND {double quote  \"}

```

**note:** Apex requires that you surround SOQL and SOSL statements with square brackets to use them in your statements. You can use Apex script variables and expressions when preceded by a colon (`:`).

**See Also**

- [_Einstein Search Help_: How Search Results are Ordered](https://help.salesforce.com/s/articleView?id=ai.search_relevancy.htm&type=5)
