# 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)
