我正在尝试将 not_analyzed 添加到网址字段。我尝试使用字段类型字符串给它未能解析映射[doc]:没有在字段[url] 上声明类型[string]的处理程序,我用文本替换了该类型,但我得到了未能解析映射[ doc]:无法将[url.index]转换为boolean 异常。我怎样才能使归档的URL not_analyzed
PUT /some_index
{
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1,
"refresh_interval": "60s",
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "my_snow","asciifolding","english_stop"]
}
},
"filter" : {
"my_snow" : {
"type" : "snowball",
"language" : "Lovins"
},
"english_stop": {
"type": "stop",
"stopwords":"_english_"
}
}
}
}
},
"mappings": {
"doc": {
"_source": {
"enabled": true
},
"properties": {
"content": {
"type": "text",
"index": "true",
"store": true,
"analyzer":"my_analyzer",
"search_analyzer": "my_analyzer"
},
"host": {
"type": "keyword",
"index": "true",
"store": true
},
"title": {
"type": "text",
"index": "true",
"store": true,
"analyzer":"my_analyzer",
"search_analyzer": "my_analyzer"
},
"url": {
"type": "text",
"index": "not_analyzed",
"store": true,
"search_analyzer": "my_analyzer"
}
}
}
}
}
最佳答案
Elasticsearch 5.0删除了not_analyzed
设置。在其位置上,string
类型分为两部分:已分析的text
和未分析的keyword
。在此博客文章上阅读更多信息:Strings are dead, long live strings!
假设您正在运行5.0+,则您的映射具有非法值。而且,这是冲突的:您说您不想分析url
,但是您指定了一个分析器:"search_analyzer": "my_analyzer"
如果不想分析该字段,则应将url字段设置为与主机相同的设置:
"url": {
"type": "keyword"
}
否则,输入
text
:"url": {
"type": "text",
"search_analyzer": "my_analyzer"
}
关于elasticsearch - 如何将not_analyzed应用于字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53119521/