More_like_this使用分词器后居然查不出来

elasticsearch版本:5.4.0
插件:ik,pinyin
jvm:1.8
setting:
PUT /testcar/
{
"index": {
"analysis": {
"analyzer": {
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": [
"my_pinyin",
"word_delimiter"
]
},
"ik_analyzer": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": [
"word_delimiter"
]
}
},
"filter": {
"my_pinyin": {

      "type": "pinyin",
      "keep_separate_first_letter": false,
      "keep_full_pinyin": true,
      "keep_original": true,
      "limit_first_letter_length": 16,
      "lowercase": true,
      "remove_duplicated_term": true
    }
  }
}

}
}
mapping:
{
"properties": {
"brand": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"brandid": {
"type": "long"
},
"caraddress": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"cc": {
"type": "long"
},
"commentcount": {
"type": "long"
},
"contacts": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"contactsphone": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"createtime": {
"type": "long"
},
"createuser": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"createusertype": {
"type": "long"
},
"des": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"detailspicurl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"exteriorpicurl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"favoritescount": {
"type": "long"
},
"firstonthecardtime": {
"type": "long"
},
"flawpicurl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"from": {
"type": "long"
},
"kilometer": {
"type": "float"
},
"lastupdatetime": {
"type": "long"
},
"licenseplate": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"model": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"modelid": {
"type": "long"
},
"price": {
"type": "long"
},
"province": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"query": {
"properties": {
"match_all": {
"type": "object"
}
}
},
"secondcarid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"size": {
"type": "long"
},
"state": {
"type": "long"
},
"style": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"ik": {
"type": "text",
"analyzer": "ik_analyzer"
},
"ik_pinyin": {
"type": "text",
"analyzer": "ik_pinyin_analyzer"
}
}
},
"transfercount": {
"type": "long"
},
"videodatamodel": {
"properties": {
"fileid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"thumbUrl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"videoDurantion": {
"type": "long"
},
"videoHeight": {
"type": "long"
},
"videoLength": {
"type": "long"
},
"videoUrl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"videoWidth": {
"type": "long"
}
}
},
"videodatastr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"viewcount": {
"type": "long"
}
}
}
插入语句:
PUT testcar/secondcar/1
{
"title":"杜卡迪"
}
PUT testcar/secondcar/2
{
"title":"杜卡迪Monster"
}
PUT testcar/secondcar/3
{
"title":"杜卡迪Monster 798"
}
PUT testcar/secondcar/4
{
"title":"杜卡迪Monster 798 7564"
}
PUT testcar/secondcar/5
{
"title":"杜卡迪Monster 798ADSADS"
}
PUT testcar/secondcar/6
{
"title":"杜卡迪Monster 798ADSADS"
}
PUT testcar/secondcar/7
{
"title":"杜卡迪Monster 798ADSADS"
}
PUT testcar/secondcar/8
{
"title":"杜卡迪Monster 798ADSADS"
}
PUT testcar/secondcar/9
{
"title":"杜卡迪Monster 798ADSADS"
}
PUT testcar/secondcar/10
{
"title":"杜卡迪Monster 798ADSADS"
}
查询语句:
ET testcar/_search
{
"query": {
"more_like_this": {
"fields": [
"title.ik"
],
"like": "杜卡迪",
"min_term_freq": 1,
"max_query_terms": 12
}
}
}
result:
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}

杜卡迪已经加入到词库中可以正常被分词。

添加参数:
,
"min_doc_freq": 0,
"min_word_len": 0,
"min_term_freq": 0

再试试

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.