2
我使用Elasticsearch 0.90.1和Kuromoji插件1.4.0。Elasticsearch:不能使用Kuromoji閱讀表格進行搜索
$ curl localhost:9200
{
"ok" : true,
"status" : 200,
"name" : "Agent Zero",
"version" : {
"number" : "0.90.1",
"snapshot_build" : false,
"lucene_version" : "4.3"
},
"tagline" : "You Know, for Search"
}
我創建新的索引,使用Kuromoji我default
分析:
$ curl -X PUT localhost:9200/test -d '{
"index": {
"analysis": {
"filter": {
"kuromoji_rf": {
"type": "kuromoji_readingform",
"use_romaji": "false"
}
},
"tokenizer": {
"kuromoji": {
"type": "kuromoji_tokenizer"
}
},
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "kuromoji",
"filter": [
"kuromoji_rf"
]
}
}
}
}
}'
結果:
{
"ok": true,
"acknowledged": true
}
的閱讀形式令牌過濾器似乎是工作的罰款(漢字歸一到片假名):
$ curl localhost:9200/test/_analyze -d '東京'
結果:
{
"tokens": [
{
"token": "トウキョウ",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
}
]
}
指數的文檔:
$ curl -X PUT localhost:9200/test/docs/1 -d '{
"body": "これは関西國際空港です"
}'
結果:
{
"ok": true,
"_index": "test",
"_type": "docs",
"_id": "1",
"_version": 1
}%
的索引文件相匹配的通配符查詢:
$ curl 'localhost:9200/test/docs/_search?q=body:*'
結果:
{
"took": 109,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "test",
"_type": "docs",
"_id": "1",
"_score": 1.0,
"_source": {
"body": "これは関西國際空港です"
}
}
]
}
}
然而,當我搜索使用日本的不匹配:
$ curl 'localhost:9200/test/docs/_search?q=body:空港'
結果:
{
"took": 21,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
$ curl 'localhost:9200/test/docs/_search?q=body:クウコウ'
結果:
{
"took": 95,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
$ curl 'localhost:9200/test/docs/_search?q=body:空'
結果:
{
"took": 22,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
我想如果可能沒有被用於搜索查詢分析器,但指定分析器沒有幫助:
$ curl 'localhost:9200/test/docs/_search?analyzer=default&q=body:空港'
結果:
{
"took": 17,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
順便說一句,一切正常罰款,如果我禁用令牌過濾器。
我在做什麼錯?
我是個白癡!謝謝。 –