【发布时间】:2013-09-22 05:08:50
【问题描述】:
我对 ES 文档感到困惑,事实上 here 他们声明索引必须放在映射目录(和索引名子目录)中:
映射可以在名为 [mapping_name].json 的文件中定义,并且可以 放置在 config/mappings/_default 位置下,或下 config/mappings/[index_name] (用于应该关联的映射 仅具有特定索引)。
然后here 在“配置”部分中声明:
索引模板也可以放在配置位置 (path.conf) 在模板目录下(注意,一定要放置 它们在所有符合条件的主节点上)。例如,一个名为 template_1.json 可以放在 config/templates 下,它将是 如果匹配索引则添加。
我将我的映射放在/config/mappings/myindexname/mappinfile.json 中,它就像:
{
"template": "maincontentindex",
"settings": {
"index": {
"analysis": {
"analyzer": {
"htmlStrippingAnalyzer": {
"tokenizer": "standard",
"filter": ["standard", "lowercase"],
"char_filter": "html_strip"
}
}
}
}
},
"mappings": {
"rendition": {
"_timestamp": {
"enabled": true,
"store" : true
},
"properties": {
"key": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"parentPage": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"type": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"language": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"device": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"territory": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"channel": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"template": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"meta": {
"properties": {
"content": {
"type": "string",
"store": "yes"
}
}
}
}
}
}
}
如果我使用 REST Api 将它放在服务器中,它工作正常,如果我调用 /maincontentindex/rendition/_mapping,我只会得到上述结构(即使没有数据)。
但是对于目录,我只会得到一个 404,如果我插入任何内容,它只是通常的动态映射。
【问题讨论】:
-
Ftr: (至少)as of ES 5.1 “不再可以在配置目录中的文件中指定映射。相反,应该使用 API 创建映射”。我强烈认为模板也是如此。
标签: json elasticsearch