2015-08-15 12:00:55 -04:00
|
|
|
[[analysis-phonetic]]
|
|
|
|
=== Phonetic Analysis Plugin
|
|
|
|
|
|
|
|
The Phonetic Analysis plugin provides token filters which convert tokens to
|
|
|
|
their phonetic representation using Soundex, Metaphone, and a variety of other
|
|
|
|
algorithms.
|
|
|
|
|
2017-04-20 09:01:37 -04:00
|
|
|
:plugin_name: analysis-phonetic
|
|
|
|
include::install_remove.asciidoc[]
|
2015-08-15 12:00:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[analysis-phonetic-token-filter]]
|
|
|
|
==== `phonetic` token filter
|
|
|
|
|
|
|
|
The `phonetic` token filter takes the following settings:
|
|
|
|
|
|
|
|
`encoder`::
|
|
|
|
|
|
|
|
Which phonetic encoder to use. Accepts `metaphone` (default),
|
2018-07-23 19:21:43 -04:00
|
|
|
`double_metaphone`, `soundex`, `refined_soundex`, `caverphone1`,
|
2015-08-15 12:00:55 -04:00
|
|
|
`caverphone2`, `cologne`, `nysiis`, `koelnerphonetik`, `haasephonetik`,
|
2018-07-23 19:21:43 -04:00
|
|
|
`beider_morse`, `daitch_mokotoff`.
|
2015-08-15 12:00:55 -04:00
|
|
|
|
|
|
|
`replace`::
|
|
|
|
|
|
|
|
Whether or not the original token should be replaced by the phonetic
|
|
|
|
token. Accepts `true` (default) and `false`. Not supported by
|
2018-07-23 19:21:43 -04:00
|
|
|
`beider_morse` encoding.
|
2015-08-15 12:00:55 -04:00
|
|
|
|
2019-09-09 13:38:14 -04:00
|
|
|
[source,console]
|
2015-08-15 12:00:55 -04:00
|
|
|
--------------------------------------------------
|
2019-01-18 03:34:11 -05:00
|
|
|
PUT phonetic_sample
|
2015-08-15 12:00:55 -04:00
|
|
|
{
|
|
|
|
"settings": {
|
|
|
|
"index": {
|
|
|
|
"analysis": {
|
|
|
|
"analyzer": {
|
|
|
|
"my_analyzer": {
|
|
|
|
"tokenizer": "standard",
|
|
|
|
"filter": [
|
|
|
|
"lowercase",
|
|
|
|
"my_metaphone"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"filter": {
|
|
|
|
"my_metaphone": {
|
|
|
|
"type": "phonetic",
|
|
|
|
"encoder": "metaphone",
|
|
|
|
"replace": false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-30 16:42:45 -04:00
|
|
|
GET phonetic_sample/_analyze
|
2016-09-22 07:54:30 -04:00
|
|
|
{
|
|
|
|
"analyzer": "my_analyzer",
|
|
|
|
"text": "Joe Bloggs" <1>
|
|
|
|
}
|
2015-08-15 12:00:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
<1> Returns: `J`, `joe`, `BLKS`, `bloggs`
|
|
|
|
|
2019-06-05 16:02:17 -04:00
|
|
|
It is important to note that `"replace": false` can lead to unexpected behavior since
|
|
|
|
the original and the phonetically analyzed version are both kept at the same token position.
|
|
|
|
Some queries handle these stacked tokens in special ways. For example, the fuzzy `match`
|
|
|
|
query does not apply {ref}/common-options.html#fuzziness[fuzziness] to stacked synonym tokens.
|
|
|
|
This can lead to issues that are difficult to diagnose and reason about. For this reason, it
|
|
|
|
is often beneficial to use separate fields for analysis with and without phonetic filtering.
|
|
|
|
That way searches can be run against both fields with differing boosts and trade-offs (e.g.
|
|
|
|
only run a fuzzy `match` query on the original text field, but not on the phonetic version).
|
2015-08-15 12:00:55 -04:00
|
|
|
|
|
|
|
[float]
|
|
|
|
===== Double metaphone settings
|
|
|
|
|
|
|
|
If the `double_metaphone` encoder is used, then this additional setting is
|
|
|
|
supported:
|
|
|
|
|
|
|
|
`max_code_len`::
|
|
|
|
|
|
|
|
The maximum length of the emitted metaphone token. Defaults to `4`.
|
|
|
|
|
|
|
|
[float]
|
|
|
|
===== Beider Morse settings
|
|
|
|
|
|
|
|
If the `beider_morse` encoder is used, then these additional settings are
|
|
|
|
supported:
|
|
|
|
|
|
|
|
`rule_type`::
|
|
|
|
|
|
|
|
Whether matching should be `exact` or `approx` (default).
|
|
|
|
|
|
|
|
`name_type`::
|
|
|
|
|
|
|
|
Whether names are `ashkenazi`, `sephardic`, or `generic` (default).
|
|
|
|
|
|
|
|
`languageset`::
|
|
|
|
|
|
|
|
An array of languages to check. If not specified, then the language will
|
2019-01-07 08:44:12 -05:00
|
|
|
be guessed. Accepts: `any`, `common`, `cyrillic`, `english`, `french`,
|
2015-08-15 12:00:55 -04:00
|
|
|
`german`, `hebrew`, `hungarian`, `polish`, `romanian`, `russian`,
|
|
|
|
`spanish`.
|