创建 Elasticsearch 索引时,我不知道将在新文档中插入哪些字段。因此,我无法在创建索引时指定哪些字段为"index": "not_analyzed"
。幸运的是,我希望所有字段都是not_analyzed
,所以有没有办法拥有整个索引或类型,即所有创建的字段not_analyzed
?
最佳答案
根据documentation在创建索引时将分析器default
或default_index
定义为keyword
类型。
例
{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "keyword"
}
}
}
}
}
您现在也可以按
type
来定义分析器的范围,但是在以后的发行版8874中它似乎已弃用。但是,当前您可以为映射中的类型设置默认分析器,如下所示:
put test/test_type/_mapping
{
"test_type" : {
"analyzer": "keyword"
}
}
关于lucene - Elasticsearch使整个索引或类型为not_analyzed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31866303/