软件版本;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"
},
========
运行环境;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"
},
========
4 个回复
JiangJibo - 喊我雷锋
赞同来自:
Tails1984
赞同来自:
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
赞同来自: