试试搜索一下吧

ik 做不到分詞searching

Elasticsearch | 作者 Tails1984 | 发布于2021年01月13日 | 阅读数:1120

软件版本;ES 7.10.1
运行环境;Oracle Linux 8
 
 入了 "張學友" 去dictionary

張學友 searching 正常

[root@localhost scripts]# curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/p_photo/_search?pretty' -d'

{
"query" : { "term" : { "caption" : "張學友" }}
}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "p_photo",
"_type" : "_doc",
"id" : "3mxa-nYBFbrkHdy06eU",
"_score" : 0.2876821,
"_source" : {
"caption" : "張學友"
}
}
]
}
}

但 "學友" searching 找不到
[root@localhost scripts]# curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/p_photo/_search?pretty' -d'

{
"query" : { "term" : { "caption" : "學友" }}
}'
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}



mapping for caption settings:
"caption": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
========
已邀请:

JiangJibo - 喊我雷锋

赞同来自:

你可以看看 张学友 分词后得到的term,有ayalysis api可以看的,如果没有分出 学友,搜不到是正常的

Tails1984

赞同来自:

ayalysis api 可以分词
 
curl -XGET "localhost:9200/p_photo/_analyze" -H 'Content-Type:application/json' -d'
{
  "text": "張學友",
  "analyzer": "ik_max_word"
}'
{"tokens":[{"token":"張學友","start_offset":0,"end_offset":3,"type":"CN_WORD","position":0}]} 
 
curl -XGET "locahost:9200/p_photo/_analyze" -H 'Content-Type:application/json' -d'
{
  "text": "學友",
  "analyzer": "ik_max_word"
}'
{"tokens":[{"token":"學","start_offset":0,"end_offset":1,"type":"CN_CHAR","position":0},{"token":"友","start_offset":1,"end_offset":2,"type":"CN_CHAR","position":1}]}

FFFrp

赞同来自:

张学友是一个词,学友分成了学和友两个词,必须张学友分出来学和友才可以被搜出来

Tails1984

赞同来自:

請問可以怎樣分出來? 感謝

要回复问题请先登录注册