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

got illegal_argument_exception when use kuromoji_neologd_tokenizer with synonym_graph #10

Open
PyYoshi opened this issue Jul 9, 2018 · 0 comments

Comments

@PyYoshi
Copy link

PyYoshi commented Jul 9, 2018

Environment

What is the problem?

Expected behavior

return HTTP Status 200.

Actual behavior

return HTTP Status 400.

Steps to reproduce the behavior

Use kuromoji_neologd_tokenizer with synonym_graph

request:

$ curl -X PUT  "localhost:9210/es63-reproduce-index?pretty" -H 'Content-Type: application/json' [email protected]

response:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "failed to build synonyms"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "failed to build synonyms",
    "caused_by" : {
      "type" : "parse_exception",
      "reason" : "Invalid synonym rule at line 1",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "term: 高等学校 analyzed to a token (高等学校) with position increment != 1 (got: 0)"
      }
    }
  },
  "status" : 400
}

reproduce.json:

{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "synonym": {
            "type": "synonym_graph",
            "synonyms": ["高校,高等学校"]
          }
        },
        "tokenizer": {
          "ja_text_tokenizer": {
            "type": "kuromoji_neologd_tokenizer",
            "mode": "search"
          }
        },
        "analyzer": {
          "ja_text_analyzer": {
            "tokenizer": "ja_text_tokenizer",
            "type": "custom",
            "filter": ["synonym"]
          }
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "name": {
          "fielddata": true,
          "type": "text",
          "analyzer": "ja_text_analyzer"
        }
      }
    }
  }
}

Use kuromoji_tokenizer with synonym_graph

request:

$ curl -X PUT  "localhost:9210/es63-reproduce-index?pretty" -H 'Content-Type: application/json' [email protected]

response:

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "es63-reproduce-index"
}

ok.json:

{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "synonym": {
            "type": "synonym_graph",
            "synonyms": ["高校,高等学校"]
          }
        },
        "tokenizer": {
          "ja_text_tokenizer": {
            "type": "kuromoji_tokenizer",
            "mode": "search"
          }
        },
        "analyzer": {
          "ja_text_analyzer": {
            "tokenizer": "ja_text_tokenizer",
            "type": "custom",
            "filter": ["synonym"]
          }
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "name": {
          "fielddata": true,
          "type": "text",
          "analyzer": "ja_text_analyzer"
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant