Search code examples
elasticsearchopensearch

How to comment on an Elasticsearch index mapping?


As I create an index used by a larger team, I need to document basics like the date, time, author, scope, etc.

Is there a comment field I can use besides the too-exposed index name?


Solution

  • You can use the _meta field in the mapping to add any custom information that suits your index.

    PUT my-index-000001
    {
      "mappings": {
        "_meta": { 
          "date": "2023-05-17",
          "time": "10:12",
          "author": "John Doe",
          "scope": "Development"
        }
      }
    }
    

    The _meta field can be updated on an existing type using the update mapping API:

    PUT my-index-000001/_mapping
    {
      "_meta": {
        "date": "2023-05-18",
        "time": "23:10",
        "author": "Jane Doe",
        "scope": "Quality"
      }
    }