Docs: revise examples

(cherry picked from commit 14ac3b0)
This commit is contained in:
Jun Ohtani 2014-12-19 16:25:51 +09:00
parent 6a19e38f68
commit 5ced1949d6
1 changed files with 150 additions and 67 deletions

217
README.md
View File

@ -127,32 +127,45 @@ User Dictionary file is placed `ES_HOME/config` directory.
### example ### example
_Example Settings:_
```sh ```sh
curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d' curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d'
{ {
"index":{ "settings": {
"analysis":{ "index":{
"tokenizer" : { "analysis":{
"kuromoji_user_dict" : { "tokenizer" : {
"type" : "kuromoji_tokenizer", "kuromoji_user_dict" : {
"mode" : "extended", "type" : "kuromoji_tokenizer",
"discard_punctuation" : "false", "mode" : "extended",
"user_dictionary" : "userdict_ja.txt" "discard_punctuation" : "false",
"user_dictionary" : "userdict_ja.txt"
}
},
"analyzer" : {
"my_analyzer" : {
"type" : "custom",
"tokenizer" : "kuromoji_user_dict"
}
} }
},
"analyzer" : {
"my_analyzer" : {
"type" : "custom",
"tokenizer" : "kuromoji_user_dict"
}
}
}
} }
} }
} }
' '
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '東京スカイツリー' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '東京スカイツリー'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "東京", "token" : "東京",
@ -177,23 +190,36 @@ This acts as a lemmatizer for verbs and adjectives.
### example ### example
_Example Settings:_
```sh ```sh
curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d' curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d'
{ {
"index":{ "settings": {
"analysis":{ "index":{
"analyzer" : { "analysis":{
"my_analyzer" : { "analyzer" : {
"tokenizer" : "kuromoji_tokenizer", "my_analyzer" : {
"filter" : ["kuromoji_baseform"] "tokenizer" : "kuromoji_tokenizer",
"filter" : ["kuromoji_baseform"]
}
} }
} }
} }
} }
} }
' '
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '飲み' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '飲み'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "飲む", "token" : "飲む",
@ -219,32 +245,45 @@ Note that default setting is stoptags.txt include lucene-analyzer-kuromoji.jar.
### example ### example
_Example Settings:_
```sh ```sh
curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d' curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d'
{ {
"index":{ "settings": {
"analysis":{ "index":{
"analyzer" : { "analysis":{
"my_analyzer" : { "analyzer" : {
"tokenizer" : "kuromoji_tokenizer", "my_analyzer" : {
"filter" : ["my_posfilter"] "tokenizer" : "kuromoji_tokenizer",
} "filter" : ["my_posfilter"]
}, }
"filter" : { },
"my_posfilter" : { "filter" : {
"type" : "kuromoji_part_of_speech", "my_posfilter" : {
"stoptags" : [ "type" : "kuromoji_part_of_speech",
"助詞-格助詞-一般", "stoptags" : [
"助詞-終助詞" "助詞-格助詞-一般",
] "助詞-終助詞"
]
}
} }
} }
} }
} }
} }
' '
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '寿司がおいしいね' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d '寿司がおいしいね'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "寿司", "token" : "寿司",
@ -277,37 +316,50 @@ Note that elasticsearch-analysis-kuromoji built-in `kuromoji_readingform` set de
### example ### example
_Example Settings:_
```sh ```sh
curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d' curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d'
{ {
"index":{ "settings": {
"analysis":{ "index":{
"analyzer" : { "analysis":{
"romaji_analyzer" : { "analyzer" : {
"tokenizer" : "kuromoji_tokenizer", "romaji_analyzer" : {
"filter" : ["romaji_readingform"] "tokenizer" : "kuromoji_tokenizer",
"filter" : ["romaji_readingform"]
},
"katakana_analyzer" : {
"tokenizer" : "kuromoji_tokenizer",
"filter" : ["katakana_readingform"]
}
}, },
"katakana_analyzer" : { "filter" : {
"tokenizer" : "kuromoji_tokenizer", "romaji_readingform" : {
"filter" : ["katakana_readingform"] "type" : "kuromoji_readingform",
} "use_romaji" : true
}, },
"filter" : { "katakana_readingform" : {
"romaji_readingform" : { "type" : "kuromoji_readingform",
"type" : "kuromoji_readingform", "use_romaji" : false
"use_romaji" : true }
},
"katakana_readingform" : {
"type" : "kuromoji_readingform",
"use_romaji" : false
} }
} }
} }
} }
} }
' '
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=katakana_analyzer&pretty' -d '寿司' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=katakana_analyzer&pretty' -d '寿司'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "スシ", "token" : "スシ",
@ -317,8 +369,17 @@ curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=katakana_an
"position" : 1 "position" : 1
} ] } ]
} }
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=romaji_analyzer&pretty' -d '寿司' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=romaji_analyzer&pretty' -d '寿司'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "sushi", "token" : "sushi",
@ -345,29 +406,42 @@ The following are settings that can be set for a `kuromoji_stemmer` token filter
### example ### example
_Example Settings:_
```sh ```sh
curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d' curl -XPUT 'http://localhost:9200/kuromoji_sample/' -d'
{ {
"index":{ "settings": {
"analysis":{ "index":{
"analyzer" : { "analysis":{
"my_analyzer" : { "analyzer" : {
"tokenizer" : "kuromoji_tokenizer", "my_analyzer" : {
"filter" : ["my_katakana_stemmer"] "tokenizer" : "kuromoji_tokenizer",
} "filter" : ["my_katakana_stemmer"]
}, }
"filter" : { },
"my_katakana_stemmer" : { "filter" : {
"type" : "kuromoji_stemmer", "my_katakana_stemmer" : {
"minimum_length" : 4 "type" : "kuromoji_stemmer",
"minimum_length" : 4
}
} }
} }
} }
} }
} }
' '
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d 'コピー' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d 'コピー'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "コピー", "token" : "コピー",
@ -377,8 +451,17 @@ curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer
"position" : 1 "position" : 1
} ] } ]
} }
```
_Example Request using `_analyze` API :_
```sh
curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d 'サーバー' curl -XPOST 'http://localhost:9200/kuromoji_sample/_analyze?analyzer=my_analyzer&pretty' -d 'サーバー'
```
_Response :_
```json
{ {
"tokens" : [ { "tokens" : [ {
"token" : "サーバ", "token" : "サーバ",