简体   繁体   English

弹性搜索文档的自定义元数据

[英]Custom metadata for elasticsearch documents

I was wandering what is the best way to add custom metadata for documents in elasticsearch. 我在徘徊是什么是为elasticsearch中的文档添加自定义元数据的最佳方式。

Lets say I have a document of type Test 假设我有一个Test类型的文档

    "Test": {
                "properties": {
                   "TestName": {
                      "type": "string"
                   },
                   "LastRunTime": {
                      "type": "string"
                   },
                   "id": {
                      "type": "string"
                   },
                   "lastUpdate": {
                      "type": "string"
                   }   
                   ....         
}

And I would like to add for each field name - a display name. 我想为每个字段名称添加一个显示名称。 eg 例如

                      "TestName": {
                          "type": "string"
                           "display_name": "Test Name"
                       },
                       "LastRunTime": {
                          "type": "string"
                           "display_name": "Last Run Time"
                       }

What is the best way to do it? 最好的方法是什么? I know there's a field called _meta in an index mapping, is this the way to go? 我知道索引映射中有一个名为_meta的字段,这是要走的路吗? I would also love if this metadata could be returned in each search query I perform on that index. 如果我在该索引上执行的每个搜索查询中都可以返回此元数据,我也很乐意。

My suggestion would be to just use another field. 我的建议是只使用另一个领域。 It doesn't have to be indexed . 它不需要编入索引 It's simpler and you can use _source filtering to retrieve or ignore it. 它更简单,您可以使用_source过滤来检索或忽略它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM