自定义分析器不工作 Elasticsearch
Custom Analyzer not working Elasticsearch
{
"_source": {
"enabled": false
},
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": "lowercase,standard,stop"
}
}
},
"mappings": {
"table": {
"properties": {
"field1": {
"type": "string",
"include_in_all": false,
"index": "no"
},
"field2": {
"type": "long",
"include_in_all": false,
"index": "no"
},
"field3": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
测试时分析仪似乎不工作。分析器不应该索引停用词,它还应该索引整个电子邮件地址。当我 "TEST ANALYZER" 并键入 "Jack is fine" 时,将对所有三个词进行索引。我不希望它索引英语中的停用词,例如 "and"、"is" 等
您将字段设置为 "index":"no" 并禁用 include_in_all
。您如何期望将某些内容放入索引中?引自 documentation:
no
means that it won’t be searchable at all (as an individual field; it may still be included in _all
). Setting to no
disables include_in_all
.
而实际的 settings
应该是这样的(您的索引定义中缺少 "settings"
):
{
"_source": {
"enabled": false
},
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": "lowercase,standard,stop"
}
}
}
},
"mappings": {
"table": {
"properties": {
"field1": {
"type": "string",
"include_in_all": false,
"index": "no"
},
"field2": {
"type": "long",
"include_in_all": false,
"index": "no"
},
"field3": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
{
"_source": {
"enabled": false
},
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": "lowercase,standard,stop"
}
}
},
"mappings": {
"table": {
"properties": {
"field1": {
"type": "string",
"include_in_all": false,
"index": "no"
},
"field2": {
"type": "long",
"include_in_all": false,
"index": "no"
},
"field3": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
测试时分析仪似乎不工作。分析器不应该索引停用词,它还应该索引整个电子邮件地址。当我 "TEST ANALYZER" 并键入 "Jack is fine" 时,将对所有三个词进行索引。我不希望它索引英语中的停用词,例如 "and"、"is" 等
您将字段设置为 "index":"no" 并禁用 include_in_all
。您如何期望将某些内容放入索引中?引自 documentation:
no
means that it won’t be searchable at all (as an individual field; it may still be included in_all
). Setting tono
disablesinclude_in_all
.
而实际的 settings
应该是这样的(您的索引定义中缺少 "settings"
):
{
"_source": {
"enabled": false
},
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": "lowercase,standard,stop"
}
}
}
},
"mappings": {
"table": {
"properties": {
"field1": {
"type": "string",
"include_in_all": false,
"index": "no"
},
"field2": {
"type": "long",
"include_in_all": false,
"index": "no"
},
"field3": {
"type": "string",
"index": "analyzed"
}
}
}
}
}