Jensxy
Jensxy

Reputation: 139

Elastic: Error when try to initialize synonym token filter

Synonym Token Filter gives an Error.

Elasticsearch version Version: 6.2.2, Build: 10b1edd/2018-02-16T19:01:30.685723Z, JVM: 1.8.0_161

Plugins installed: Opennlp

JVM version java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

OS version Linux server 4.4.0-131-generic #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

When I try to reproduce the following: https://qbox.io/blog/synonym-token-filter-wordnet-applications

However, if I change the tokenizer to "standard", instead of "lowercase", everything is fine. Does anyone have an idea what to do?

I get the following error.

Error: 400 - failed to build synonyms ES stack trace:

type: illegal_argument_exception reason: failed to build synonyms

Steps to reproduce:

curl -XPUT 'localhost:9200/test_index' -d '{
 "analysis": {
    "filter": {
      "synonym": {
        "type": "synonym",
        "format": "wordnet",
        "synonyms_path": "analysis/wn_s.pl"
      }
    },
    "analyzer": {
      "wordnet-synonym-analyzer": {
        "tokenizer": "lowercase",
        "filter": [
          "synonym"
        ]
      }
    }
  }
}'

Upvotes: 0

Views: 681

Answers (1)

mohammad asghari
mohammad asghari

Reputation: 1884

Try this:

Use standard tokenizer and add lowercase as filter.

"analyzer": {
  "synonymAnalyzer": {
    "type": "custom",
    "tokenizer": "standard",
    "filter": [
      "lowercase",
      "synonym"
    ]
  }
}

Upvotes: 1

Related Questions