elasticsearch 理解麋鹿分析仪
我是麋鹿5.1.1堆栈的新手,我有几个问题需要了解。 我已经用标准分析仪/过滤器设置了这个堆栈,一切都很好。 我的数据源是一个MySQL后端,我使用Logstash对其进行索引。 我想处理包含重音的查询,希望AsciFolding标记过滤器能够帮助实现这一点 首先,我学习了如何创建自定义分析器和另存为模板。 现在当我查询这个url时http://localhost:9200/_template?pretty 我有两个模板:名为logstash的logstash默认模板和我的自定义模板,设置如下:elasticsearch 理解麋鹿分析仪,elasticsearch,logstash,elastic-stack,elasticsearch,Logstash,Elastic Stack,我是麋鹿5.1.1堆栈的新手,我有几个问题需要了解。 我已经用标准分析仪/过滤器设置了这个堆栈,一切都很好。 我的数据源是一个MySQL后端,我使用Logstash对其进行索引。 我想处理包含重音的查询,希望AsciFolding标记过滤器能够帮助实现这一点 首先,我学习了如何创建自定义分析器和另存为模板。 现在当我查询这个url时http://localhost:9200/_template?pretty 我有两个模板:名为logstash的logstash默认模板和我的自定义模板,设置如下:
"custom_template" : {
"order" : 1,
"template" : "doo*",
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"myCustomAnalyzer" : {
"filter" : [
"standard",
"lowercase",
"asciifolding"
],
"tokenizer" : "standard"
}
}
},
"refresh_interval" : "5s"
}
},
"mappings" : { },
"aliases" : { }
}
搜索关键词雅温得会返回70次点击,但当我搜索雅温得时,我一直没有点击。
下面是我对第二个案例的质疑
{
"query": {
"query_string": {
"query": "yaounde",
"fields": [
"title"
]
}
},
"from": 0,
"size": 10
}
有人能帮我猜猜我做错了什么吗?
我还知道,在索引过程中,我的数据是通过Logstash进行分析的,我真的必须根据第二个查询指定在研究过程中应用analyzer myCustomAnalyzer吗
{
"query": {
"query_string": {
"query": "yaounde",
"fields": [
"title"
],
"analyzer": "myCustomAnalyzer"
}
},
"from": 0,
"size": 10
}
下面是我的logstash配置文件的输出部分的示例
output {
stdout { codec => json_lines }
if [type] == "announces" {
elasticsearch {
hosts => "localhost:9200"
document_id => "%{job_id}"
index => "dooone"
document_type => "%{type}"
}
} else {
elasticsearch {
hosts => "localhost:9200"
document_id => "%{uid}"
index => "dootwo"
document_type => "%{type}"
}
}
}
谢谢您能显示文档的映射吗 获取/my_index/my_doc/\u映射 在查询中作为参数提供的分析器仅在搜索时适用,而在索引时不适用。因此,如果尚未在映射中设置此分析器,则该字符串仍然使用默认分析器编制索引,因此它将与您的结果不匹配
您在搜索时提供的分析器将应用于您的查询字符串,但随后它将查找索引数据,索引为雅温得,而不是雅温得。一个好的起点是elasticsearch的索引模板文档: 可以用于标题字段的场景示例:
"custom_template" : {
"order" : 1,
"template" : "doo*",
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"myCustomAnalyzer" : {
"filter" : [
"standard",
"lowercase",
"asciifolding"
],
"tokenizer" : "standard"
}
}
},
"refresh_interval" : "5s"
}
},
"mappings" : {
"your_type": {
"properties": {
"title": {
"type": "text",
"analyzer": "myCustomAnalyzer"
}
}
}
},
"aliases" : { }
}
另一种方法是更改动态映射。你可以在这里找到一个关于字符串的好例子。
是否向字段标题添加了映射?从您的代码示例中不太清楚。现在我的字段的映射是在索引过程中由Logstash自动设置的。这是否回答了您的问题@JettroCoenradie?现在如果我查询此url,它会显示类似于此图像的内容[![此图像][1]][1][1]:如果我愿意的话http://localhost:8270/dooone/_settings?pretty 它显示了正确的设置,我已经设置为我的模板,然后通过logstash进行索引。你能提供你的模板吗?我必须使用定义分析器来在映射部分使用映射:{…}我的问题最终解决了。谢谢你的帮助,谢谢。成功了!我使用您的解决方案为我的标题字段定义了一个映射,它成功了。