重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
需求:
创新互联专注于岱山企业网站建设,响应式网站开发,商城网站开发。岱山网站建设公司,为岱山等地区提供建站服务。全流程定制网站建设,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务IK分词:
GitHub - medcl/elasticsearch-analysis-ik: The IK Analysis plugin integrates Lucene IK analyzer into elasticsearch, support customized dictionary.
拼音:
https://github.com/medcl/elasticsearch-analysis-pinyin
简繁体:
ehttps://github.com/medcl/elasticsearch-analysis-stconvert
analysis分析是 Elasticsearch 在文档发送之前对文档正文执行的过程,以添加到反向索引中(inverted index)。 在将文档添加到索引之前,Elasticsearch 会为每个分析的字段执行许多步骤:
详细介绍:Elasticsearch: analyzer_Elastic 中国社区官方博客的博客-博客_elasticsearch analyzer如果大家之前看过我写的文章“开始使用Elasticsearch (3)”,在文章的最后部分写了有关于analyzer的有关介绍。在今天的文章中,我们来进一步了解analyzer。 analyzer执行将输入字符流分解为token的过程,它一般发生在两个场合:在indexing的时候,也即在建立索引的时候在searching的时候,也即在搜索时,分析需要搜索的词语什么是analysis...https://blog.csdn.net/UbuntuTouch/article/details/100392478
三、索引模板PUT /_template/test_template
{
"index_patterns": [
"test-*"
],
"aliases": {
"test_read": {}
},
"settings": {
"index": {
"max_result_window": "100000",
"refresh_interval": "5s",
"number_of_shards": "5",
"translog": {
"flush_threshold_size": "1024mb",
"sync_interval": "30s",
"durability": "async"
},
"number_of_replicas": "1"
},
"analysis": {
"char_filter": {
"tsconvert": {
"type": "stconvert",
"convert_type": "t2s"
}
},
"analyzer": {
"ik_t2s_pinyin_analyzer": {
"type": "custom",
"char_filter": [
"tsconvert"
],
"tokenizer": "ik_max_word",
"filter": [
"pinyin_filter",
"lowercase"
]
},
"stand_t2s_pinyin_analyzer": {
"type": "custom",
"char_filter": [
"tsconvert"
],
"tokenizer": "standard",
"filter": [
"pinyin_filter",
"lowercase"
]
},
"ik_t2s_analyzer": {
"type": "custom",
"char_filter": [
"tsconvert"
],
"tokenizer": "ik_max_word",
"filter": [
"lowercase"
]
},
"stand_t2s_analyzer": {
"type": "custom",
"char_filter": [
"tsconvert"
],
"tokenizer": "standard",
"filter": [
"lowercase"
]
},
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_max_word",
"filter": [
"pinyin_filter",
"lowercase"
]
},
"stand_pinyin_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"pinyin_filter",
"lowercase"
]
}
},
"filter": {
"pinyin_first_letter_and_full_pinyin_filter": {
"type": "pinyin",
"keep_first_letter": true,
"keep_separate_first_letter": false,
"keep_full_pinyin": false,
"keep_joined_full_pinyin": true,
"keep_none_chinese": true,
"none_chinese_pinyin_tokenize": false,
"keep_none_chinese_in_joined_full_pinyin": true,
"keep_original": false,
"limit_first_letter_length": 1000,
"lowercase": true,
"trim_whitespace": true,
"remove_duplicated_term": true
}
}
}
},
"mappings": {
"properties": {
"name": {
"index_phrases": true,
"analyzer": "ik_max_word",
"index": true,
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
},
"stand": {
"analyzer": "standard",
"type": "text"
},
"STPA": {
"type": "text",
"analyzer": "stand_t2s_pinyin_analyzer"
},
"ITPA": {
"type": "text",
"analyzer": "ik_t2s_pinyin_analyzer"
}
}
},
"desc": {
"index_phrases": true,
"analyzer": "ik_max_word",
"index": true,
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
},
"stand": {
"analyzer": "standard",
"type": "text"
},
"STPA": {
"type": "text",
"analyzer": "stand_t2s_pinyin_analyzer"
},
"ITPA": {
"type": "text",
"analyzer": "ik_t2s_pinyin_analyzer"
}
}
},
"abstr": {
"index_phrases": true,
"analyzer": "ik_max_word",
"index": true,
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
},
"stand": {
"analyzer": "standard",
"type": "text"
},
"STPA": {
"type": "text",
"analyzer": "stand_t2s_pinyin_analyzer"
},
"ITPA": {
"type": "text",
"analyzer": "ik_t2s_pinyin_analyzer"
}
}
}
}
}
}
四、DSL语句GET /test_read/_search
{
"from": 0,
"size": 10,
"terminate_after": 100000,
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "bj天安门 OR 测试",
"fields": [
"name.ITPA"
],
"type": "phrase",
"default_operator": "and"
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"post_filter": {
"bool": {
"must": [
{
"match": {
"name": "天安门"
}
}
]
}
},
"highlight": {
"fragment_size": 1000,
"pre_tags": [
""
],
"post_tags": [
""
],
"fields": {
"name.stand": {},
"desc.stand": {},
"abstr.stand": {},
"name.IPA": {},
"desc.IPA": {},
"abstr.IPA": {},
"name.ITPA": {},
"desc.ITPA": {},
"abstr.ITPA": {}
}
}
}
post_filter:后过滤器 | Elasticsearch: 权威指南 | Elastic
PS:post_filter实现二次搜索功能,post_filter无法使用es高亮功能,需要自己通过代码进行手动标记高亮;根据上面的DSL语句,可写出对应的代码啦~
拼音插件配置:
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧