# Phone numbers

The same number is written `(415) 555-2671`, `+1 415 555 2671` and `415.555.2671`, and people
search for it by its last four digits. The `phone` analyzer reads a phone number in any common
format and indexes it in its international form (`+14155552671`), its digits with and without the
country code, and its trailing digits down to four. So all three forms match each other, and a
search for `2671` finds the number. Extensions are ignored, and digits in other scripts, such as
Arabic-Indic or fullwidth, are read as digits.

```json
{"fields": {"phone": {"type": "text", "analyzer": "phone"}}}
```

Use the `phone_search` analyzer instead when only a whole number should match: it indexes the
international form and the national number, without the trailing-digit forms.

## Other regions

Numbers written without a country code are read as US numbers. For another region, use the
tokenizer with `default_region`:

```json
{
  "type": "text",
  "analyzer": {"tokenizer": {"name": "phone", "params": {"default_region": "GB"}}}
}
```

| Param | Tokenizer | Default | Meaning |
|---|---|---|---|
| `default_region` | `phone`, `phone_search` | `US` | ISO 3166 country code for numbers without a `+` prefix. |
| `emit_suffixes` | `phone` | `true` | Index the trailing-digit forms. |
| `min_suffix_length` | `phone` | `4` | Shortest trailing-digit form indexed. |

## Notes

- A value that is not a valid phone number is indexed as its digits.
- The `phone_digits` filter keeps a leading `+` and the digits of each token and can follow any
  tokenizer.
- The OpenSearch `phone` and `phone-search` analyzers and tokenizers map to these, and
  `phone-region` sets `default_region`. See
  [Through the compatible APIs](text-analysis.md#through-the-compatible-apis).
