Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beider_morse phonetic encoder silently fails when languageset not specified #26771

Closed
bkazez opened this issue Sep 25, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@bkazez
Copy link

commented Sep 25, 2017

Elasticsearch version: Version: 5.6.0, Build: 781a835/2017-09-07T03:09:58.087Z, JVM: 1.8.0_144

Plugins installed: ["analysis-phonetic"]

JVM version: java version "1.8.0_144"

OS version : 16.7.0 Darwin Kernel Version 16.7.0 (OS X 10.12.6)

Description of the problem including expected versus actual behavior: Beider-Morse encoding fails silently (returns original string as token) if the languageset is not specified.

Steps to reproduce:

curl -XPUT 'http://localhost:9200/phonetictest?pretty' -d'{
  "settings": {
    "analysis": {
      "filter": {
        "beider_morse_filter": { 
          "type":    "phonetic",
          "encoder": "beider_morse",
          "name_type": "generic"
        }
      },
      "analyzer": {
        "my_beider_morse": {
          "tokenizer": "standard",
          "filter":    "beider_morse_filter" 
        }
      }
    }
  }
}'

curl -XGET 'http://localhost:9200/phonetictest/_analyze?pretty&analyzer=my_beider_morse' -d'ABADIAS'

Incorrectly returns:

{
  "tokens" : [
    {
      "token" : "ABADIAS",
      "start_offset" : 0,
      "end_offset" : 7,
      "type" : "<ALPHANUM>",
      "position" : 0
    }
  ]
}

Expected token list based on the current BMPM PHP code at http://stevemorse.org/phoneticinfo.htm :

abadias abadia abadios abadio abodias abodia abodios abodio abYdias abYdios avadias avadios avodias avodios obadias obadia obadios obadio obodias obodia obodios obodio obYdias obYdios ovadias ovadios ovodias ovodios Ybadias Ybadios Ybodias Ybodios YbYdias YbYdios abadiaS abadioS abodiaS abodioS obadiaS obadioS obodiaS obodioS

Similar failures occurred with all other attempts.

@jpountz

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2017

The problem seems to be because of this.languageset = settings.getAsArray("languageset"); in PhoneticTokenFilterFactory which returns an empty array rather than null when no languageset is defined. Would you like to work on a fix?

@bkazez

This comment has been minimized.

Copy link
Author

commented Oct 1, 2017

Submitted pull request to fix this: #26848

bkazez added a commit to bkazez/elasticsearch that referenced this issue Oct 2, 2017

cbuescher added a commit to cbuescher/elasticsearch that referenced this issue Oct 25, 2017

Fix beidermorse phonetic token filter for unspecified `languageset`
Currently, when we create a BeiderMorseFilter with an unspecified `languageset`,
the filter will not guess the language, which should be the default behaviour.
This change fixes this and adds a simple test for the cases with and without
provided `languageset` settings.

Closes elastic#26771

@cbuescher cbuescher self-assigned this Oct 25, 2017

cbuescher added a commit that referenced this issue Oct 27, 2017

Fix beidermorse phonetic token filter for unspecified `languageset` (#…
…27112)

Currently, when we create a BeiderMorseFilter with an unspecified `languageset`,
the filter will not guess the language, which should be the default behaviour.
This change fixes this and adds a simple test for the cases with and without
provided `languageset` settings.

Closes #26771

cbuescher added a commit that referenced this issue Oct 27, 2017

Fix beidermorse phonetic token filter for unspecified `languageset` (#…
…27112)

Currently, when we create a BeiderMorseFilter with an unspecified `languageset`,
the filter will not guess the language, which should be the default behaviour.
This change fixes this and adds a simple test for the cases with and without
provided `languageset` settings.

Closes #26771

cbuescher added a commit that referenced this issue Oct 27, 2017

Fix beidermorse phonetic token filter for unspecified `languageset` (#…
…27112)

Currently, when we create a BeiderMorseFilter with an unspecified `languageset`,
the filter will not guess the language, which should be the default behaviour.
This change fixes this and adds a simple test for the cases with and without
provided `languageset` settings.

Closes #26771

cbuescher added a commit that referenced this issue Oct 27, 2017

Fix beidermorse phonetic token filter for unspecified `languageset` (#…
…27112)

Currently, when we create a BeiderMorseFilter with an unspecified `languageset`,
the filter will not guess the language, which should be the default behaviour.
This change fixes this and adds a simple test for the cases with and without
provided `languageset` settings.

Closes #26771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.