我正在尝试将 not_analyzed 添加到网址字段。我尝试使用它给我的字段类型字符串无法解析映射[doc]:没有在字段[url]上声明类型[string]的处理程序,我用文本替换了该类型,我得到了< strong>无法解析映射[doc]:无法将[url.index]转换为布尔值。我怎样才能使归档的网址成为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"
}
}
}
}
}
答案 0 :(得分:1)
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"
}