meta-field.asciidoc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [[mapping-meta-field]]
  2. === `_meta` field
  3. A mapping type can have custom meta data associated with it. These are not
  4. used at all by Elasticsearch, but can be used to store application-specific
  5. metadata, such as the class that a document belongs to:
  6. [source,js]
  7. --------------------------------------------------
  8. PUT my_index
  9. {
  10. "mappings": {
  11. "_doc": {
  12. "_meta": { <1>
  13. "class": "MyApp::User",
  14. "version": {
  15. "min": "1.0",
  16. "max": "1.3"
  17. }
  18. }
  19. }
  20. }
  21. }
  22. --------------------------------------------------
  23. // CONSOLE
  24. <1> This `_meta` info can be retrieved with the
  25. <<indices-get-mapping,GET mapping>> API.
  26. The `_meta` field can be updated on an existing type using the
  27. <<indices-put-mapping,PUT mapping>> API:
  28. [source,js]
  29. --------------------------------------------------
  30. PUT my_index/_mapping/_doc
  31. {
  32. "_meta": {
  33. "class": "MyApp2::User3",
  34. "version": {
  35. "min": "1.3",
  36. "max": "1.5"
  37. }
  38. }
  39. }
  40. --------------------------------------------------
  41. // CONSOLE
  42. // TEST[continued]