Created
June 18, 2020 15:37
-
-
Save johtani/8c7df642a001d11881a72f94669fbd21 to your computer and use it in GitHub Desktop.
Elasticsearch勉強会のデモで利用したDevConsoleのスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## version 7.9で動作するはずです。 discard_compound_tokenの設定は7.8までは動作しないです(それ以外については動作します。) | |
DELETE en_synonym_test | |
PUT en_synonym_test | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"en_synonym": { | |
"type": "custom", | |
"tokenizer": "whitespace", | |
"filter": ["en_synonym"] | |
} | |
}, | |
"filter": { | |
"en_synonym": { | |
"type": "synonym_graph", | |
"synonyms": ["ipod, i-pod, i pod"] | |
} | |
} | |
} | |
} | |
} | |
# サンプル For Enlglish | |
GET en_synonym_test/_analyze | |
{ | |
"text": "I want i-pod", | |
"analyzer": "en_synonym" | |
} | |
# Kuromojiの挙動の確認 | |
GET _analyze | |
{ | |
"text": "それは株式会社です", | |
"tokenizer": "kuromoji_tokenizer", | |
"explain": false | |
,"attributes": ["partOfSpeech", "reading"] | |
} | |
DELETE synonym_test | |
# 日本語の類義語を作ってみる(エラー) | |
PUT synonym_test | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"kuromoji_synonym": { | |
"type": "custom", | |
"tokenizer": "kuromoji_tokenizer", | |
"filter": ["ja_synonym"] | |
} | |
}, | |
"filter": { | |
"ja_synonym": { | |
"type": "synonym_graph", | |
"synonyms": [ | |
"株式会社, コーポレーション" | |
] | |
} | |
} | |
} | |
} | |
} | |
# Kuromoji Tokenizer(デフォルト) | |
GET _analyze | |
{ | |
"text": "株式会社", | |
"tokenizer": "kuromoji_tokenizer" | |
} | |
# Kuromoji Tokenizer(mode=normal) | |
GET _analyze | |
{ | |
"text": "株式会社", | |
"tokenizer": { | |
"type": "kuromoji_tokenizer", | |
"mode": "normal" | |
} | |
} | |
DELETE synonym_test | |
# mode=normalで再チャレンジ | |
PUT synonym_test | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"kuromoji_synonym": { | |
"type": "custom", | |
"tokenizer": "ja_tokenizer", | |
"filter": ["ja_synonym"] | |
} | |
}, | |
"tokenizer": { | |
"ja_tokenizer": { | |
"type": "kuromoji_tokenizer", | |
"mode": "normal" | |
} | |
}, | |
"filter": { | |
"ja_synonym": { | |
"type": "synonym_graph", | |
"synonyms": [ | |
"株式会社, コーポレーション" | |
] | |
} | |
} | |
} | |
} | |
} | |
# 無事類義語展開されるけど。。。 | |
GET synonym_test/_analyze | |
{ | |
"text": "株式会社", | |
"analyzer": "kuromoji_synonym" | |
} | |
# LUCENE-9123 | |
GET _analyze | |
{ | |
"text": "それは株式会社です", | |
"tokenizer": { | |
"type": "kuromoji_tokenizer", | |
"discard_compound_token": true | |
}, | |
"explain": false | |
,"attributes": ["partOfSpeech", "reading"] | |
} | |
DELETE synonym_test | |
PUT synonym_test | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"kuromoji_synonym": { | |
"type": "custom", | |
"tokenizer": "ja_tokenizer", | |
"filter": ["ja_synonym"] | |
} | |
}, | |
"tokenizer": { | |
"ja_tokenizer": { | |
"type": "kuromoji_tokenizer", | |
"discard_compound_token": true | |
} | |
}, | |
"filter": { | |
"ja_synonym": { | |
"type": "synonym_graph", | |
"synonyms": [ | |
"株式会社, コーポレーション" | |
] | |
} | |
} | |
} | |
} | |
} | |
GET synonym_test/_analyze | |
{ | |
"text": "それはコーポレーションです", | |
"analyzer": "kuromoji_synonym", | |
"explain": false | |
,"attributes": ["partOfSpeech", "reading"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment