我正在尝试使用不同的分析器设置索引以进行索引和搜索。 SENSE我输入以下代码:
PUT my_index
{
"mappings" : {
"my_type" : {
"properties" : {
"content" : {
"type" : "string",
"index": "analyzed",
"analyzer": "my_index_analyzer"
}
}
}
},
"settings" : {
"number_of_shards" : 1,
"analysis" : {
"filter" : {
"my_filter" : {
"type" : "pattern_capture",
"preserve_original" :1,
"patterns" : ["(([a-z]+)(\\d*))"]
}},
"index_analyzer" : {
"my_index_analyzer" : {
"tokenizer" : "standard",
"type" : "custom",
"filter" : ["my_filter"]
}},
"search_analyzer" : {
"my_search_analyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase"]
}
}
}
}
}
但这似乎不起作用; ES实例总是返回错误,如
MapperParsingException [mapping [my_type]];嵌套: 找不到MapperParsingException [Analyzer [my_index_analyzer] field [content]]
答案 0 :(得分:1)
将您的分析仪部件更改为
"analyzer": {
"my_index_analyzer" : {
"tokenizer" : "standard",
"type" : "custom",
"filter" : ["my_filter"]
},
"my_search_analyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase"]
}
}
}
并将映射部分更改为:
"properties" : {
"content" : {
"type" : "string",
"index": "analyzed",
"index_analyzer": "my_index_analyzer",
"search_analyzer": "my_search_analyzer"
}
}