【发布时间】:2018-06-21 13:20:00
【问题描述】:
如何在不使用默认内置标记过滤器的情况下创建自定义标记器?例如:文本:“三星 Galaxy S9” 我想标记这个文本,以便它应该像这样被索引
["samsung", "galaxy", "s9", "samsung galaxy s9", "samsung s9", "samsung galaxy" , "galaxy s9"].
我该怎么做?
【问题讨论】:
如何在不使用默认内置标记过滤器的情况下创建自定义标记器?例如:文本:“三星 Galaxy S9” 我想标记这个文本,以便它应该像这样被索引
["samsung", "galaxy", "s9", "samsung galaxy s9", "samsung s9", "samsung galaxy" , "galaxy s9"].
我该怎么做?
【问题讨论】:
PUT testindex
{
"settings": {
"analysis": {
"filter": {
"filter_shingle": {
"type": "shingle",
"max_shingle_size": 20,
"min_shingle_size": 2,
"output_unigrams": "true"
}
},
"analyzer": {
"analyzer_shingle": {
"tokenizer": "whitespace",
"filter": [
"lowercase",
"filter_shingle"
]
}
}
}
},
"mappings": {
"product": {
"properties": {
"title": {
"analyzer": "analyzer_shingle",
"search_analyzer": "standard",
"type": "text"
}
}
}
}
}
POST testindex/product/1
{
"title": "Samsung Galaxy S9"
}
GET testindex/_analyze
{
"analyzer": "analyzer_shingle",
"text": ["Samsung Galaxy S9"]
}
第一个例子很棒,涵盖了很多内容。如果您想使用标准标记器而不是空格,那么您必须按照博客文章的描述处理停用词。两个url都是ES官方源
【讨论】:
#! Deprecation: Deprecated big difference between maxShingleSize and minShingleSize in Shingle TokenFilter,expected difference must be less than or equal to: [3]