ES之RestAPI实现自动补全
Posted SmallPepsi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ES之RestAPI实现自动补全相关的知识,希望对你有一定的参考价值。
创建索引库的DSL语句
// 酒店数据索引库
PUT /hotel
"settings":
"analysis":
"analyzer":
"text_anlyzer":
"tokenizer": "ik_max_word",
"filter": "py"
,
"completion_analyzer":
"tokenizer": "keyword",
"filter": "py"
,
"filter":
"py":
"type": "pinyin",
"keep_full_pinyin": false,
"keep_joined_full_pinyin": true,
"keep_original": true,
"limit_first_letter_length": 16,
"remove_duplicated_term": true,
"none_chinese_pinyin_tokenize": false
,
"mappings":
"properties":
"id":
"type": "keyword"
,
"name":
"type": "text",
"analyzer": "text_anlyzer",
"search_analyzer": "ik_smart",
"copy_to": "all"
,
"address":
"type": "keyword",
"index": false
,
"price":
"type": "integer"
,
"score":
"type": "integer"
,
"brand":
"type": "keyword",
"copy_to": "all"
,
"city":
"type": "keyword"
,
"starName":
"type": "keyword"
,
"business":
"type": "keyword",
"copy_to": "all"
,
"location":
"type": "geo_point"
,
"pic":
"type": "keyword",
"index": false
,
"all":
"type": "text",
"analyzer": "text_anlyzer",
"search_analyzer": "ik_smart"
,
"suggestion":
"type": "completion",
"analyzer": "completion_analyzer"
以上是关于ES之RestAPI实现自动补全的主要内容,如果未能解决你的问题,请参考以下文章
ES系列Elasticsearch Suggester API(自动补全)
ES系列Elasticsearch Suggester API(自动补全)