diff --git a/_install-and-configure/additional-plugins/analysis-phonenumber-plugin.md b/_install-and-configure/additional-plugins/analysis-phonenumber-plugin.md new file mode 100644 index 00000000000..4ee3c7e6f41 --- /dev/null +++ b/_install-and-configure/additional-plugins/analysis-phonenumber-plugin.md @@ -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://github.com/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://github.com/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" + } + } + } +} +``` diff --git a/_install-and-configure/additional-plugins/index.md b/_install-and-configure/additional-plugins/index.md index 87d06624423..d4c3b219f61 100644 --- a/_install-and-configure/additional-plugins/index.md +++ b/_install-and-configure/additional-plugins/index.md @@ -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://github.com/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 | 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