Source 源文档属性 #
_source 字段包含已索引的原始 JSON 文档主体。虽然此字段不可搜索,但它会被存储,以便在执行获取请求(如 get 和 search)时可以返回完整文档。
禁用_source
#
您可以通过将 enabled 参数设置为 false 来禁用 _source 字段,如以下示例所示:
PUT sample-index1
{
"mappings": {
"_source": {
"enabled": false
}
}
}
禁用
_source字段可能会影响某些功能的可用性,例如update、update_by_query和reindexAPI,以及使用原始索引文档查询或聚合的能力。
包含或排除某些字段 #
您可以使用 includes 和 excludes 参数选择 _source 字段的内容。如以下示例:
PUT logs
{
"mappings": {
"_source": {
"includes": [
"*.count",
"meta.*"
],
"excludes": [
"meta.description",
"meta.other.*"
]
}
}
}
这些字段不会存储在 _source 中,但您仍然可以搜索它们,因为数据仍然被索引。