9

I was wandering what is the best way to add custom metadata for documents in elasticsearch.

Lets say I have a document of type 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. e.g.

                      "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? I would also love if this metadata could be returned in each search query I perform on that index.

Lital Kolog
  • 1,301
  • 14
  • 39
  • 1
    The _meta portion of the index mapping appears to be the only approach. https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-fields.html. That is not returned in the results of a search. – John Meagher Aug 15 '17 at 04:36

1 Answers1

1

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.

cmantas
  • 1,516
  • 14
  • 14