Skip to content

Commit

Permalink
document the new analysis-phonenumber plugin
Browse files Browse the repository at this point in the history
this is part of opensearch-project/OpenSearch#11326. the actual
implementation was done opensearch-project/OpenSearch#15915. see the
commit message on the PR for further details.

resolves opensearch-project#8389

Signed-off-by: Ralph Ursprung <[email protected]>
  • Loading branch information
rursprung committed Oct 4, 2024
1 parent 59bea71 commit 4953b46
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
layout: default
title: Phone number analysis plugin
parent: Installing plugins
nav_order: 20

---

# Phone number analysis plugin
Introduced 2.18
{: .label .label-purple }

The `analysis-phonenumber` plugin provides analysers and tokenizers for phone numbers.
A dedicated analyser is required since parsing phone numbers is a non-trivial task (even though it might seem trivial at
first glance!), as can be seen in the list [falsehoods programmers believe about phone numbers](https:/google/libphonenumber/blob/master/FALSEHOODS.md).

## Installing the plugin

Install the `analysis-phonenumber` plugin using the following command:

```sh
./bin/opensearch-plugin install analysis-phonenumber
```

## Provided analyzers & tokenizers

There are two analyzers & tokenizers being provided:
* `phone`: use this as the [index analyzer]({{site.url}}{{site.baseurl}}/analyzers/index-analyzers/)
* `phone-search`: use this as the [search analyzer]({{site.url}}{{site.baseurl}}/analyzers/search-analyzers/)

You can optionally specify a default region which it should use when parsing phone numbers. When tokenizing phone numbers
with the international calling prefix `+` this is not relevant, but for phone numbers which either use a national prefix
for international numbers (e.g. `001` instead of `+1` to dial Northern America from most European countries) the region
needs to be known. Furthermore you can also properly index local phone numbers with no international prefix if you specify
the region.

Internally this uses [libphonenumber](https:/google/libphonenumber), thus their parsing rules apply.

Note that these analyzers are not meant to find phone numbers in larger texts, instead you should use them on fields which
contain the phone number.

## Example

Example configuration of an index with one field which ingests phone numbers for Switzerland:
```json
PUT /example-phone
{
"settings": {
"analysis": {
"analyzer": {
"phone-ch": {
"type": "phone",
"phone-region": "CH"
},
"phone-search-ch": {
"type": "phone-search",
"phone-region": "CH"
}
}
}
},
"mappings": {
"properties": {
"phoneNumber": {
"type": "text",
"analyzer": "phone-ch",
"search_analyzer": "phone-search-ch"
}
}
}
}
```
47 changes: 24 additions & 23 deletions _install-and-configure/additional-plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@ nav_order: 10

There are many more plugins available in addition to those provided by the standard distribution of OpenSearch. These additional plugins have been built by OpenSearch developers or members of the OpenSearch community. While it isn't possible to provide an exhaustive list (because many plugins are not maintained in an OpenSearch GitHub repository), the following plugins, available in the [OpenSearch/plugins](https:/opensearch-project/OpenSearch/tree/main/plugins) directory on GitHub, are some of the plugins that can be installed using one of the installation options, for example, using the command `bin/opensearch-plugin install <plugin-name>`.

| Plugin name | Earliest available version |
| :--- | :--- |
| analysis-icu | 1.0.0 |
| analysis-kuromoji | 1.0.0 |
| analysis-nori | 1.0.0 |
| analysis-phonetic | 1.0.0 |
| analysis-smartcn | 1.0.0 |
| analysis-stempel | 1.0.0 |
| analysis-ukrainian | 1.0.0 |
| discovery-azure-classic | 1.0.0 |
| discovery-ec2 | 1.0.0 |
| discovery-gce | 1.0.0 |
| [`ingest-attachment`]({{site.url}}{{site.baseurl}}/install-and-configure/additional-plugins/ingest-attachment-plugin/) | 1.0.0 |
| mapper-annotated-text | 1.0.0 |
| mapper-murmur3 | 1.0.0 |
| [`mapper-size`]({{site.url}}{{site.baseurl}}/install-and-configure/additional-plugins/mapper-size-plugin/) | 1.0.0 |
| query-insights | 2.12.0 |
| repository-azure | 1.0.0 |
| repository-gcs | 1.0.0 |
| repository-hdfs | 1.0.0 |
| repository-s3 | 1.0.0 |
| store-smb | 1.0.0 |
| transport-nio | 1.0.0 |
| Plugin name | Earliest available version |
|:-----------------------------------------------------------------------------------------------------------------------------|:---------------------------|
| analysis-icu | 1.0.0 |
| analysis-kuromoji | 1.0.0 |
| analysis-nori | 1.0.0 |
| [`analysis-phonenumber`]({{site.url}}{{site.baseurl}}/install-and-configure/additional-plugins/analysis-phonenumber-plugin/) | 2.18.0 |
| analysis-phonetic | 1.0.0 |
| analysis-smartcn | 1.0.0 |
| analysis-stempel | 1.0.0 |
| analysis-ukrainian | 1.0.0 |
| discovery-azure-classic | 1.0.0 |
| discovery-ec2 | 1.0.0 |
| discovery-gce | 1.0.0 |
| [`ingest-attachment`]({{site.url}}{{site.baseurl}}/install-and-configure/additional-plugins/ingest-attachment-plugin/) | 1.0.0 |
| mapper-annotated-text | 1.0.0 |
| mapper-murmur3 | 1.0.0 |
| [`mapper-size`]({{site.url}}{{site.baseurl}}/install-and-configure/additional-plugins/mapper-size-plugin/) | 1.0.0 |
| query-insights | 2.12.0 |
| repository-azure | 1.0.0 |
| repository-gcs | 1.0.0 |
| repository-hdfs | 1.0.0 |
| repository-s3 | 1.0.0 |
| store-smb | 1.0.0 |
| transport-nio | 1.0.0 |

## Related articles

Expand Down

0 comments on commit 4953b46

Please sign in to comment.