Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom metadata for elasticsearch documents

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.

like image 524
Lital Kolog Avatar asked May 18 '15 09:05

Lital Kolog


1 Answers

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.

like image 56
cmantas Avatar answered Sep 23 '22 23:09

cmantas