index template由两部分组成,一个是setting一个是mapping

    1. PUT _component_template/component_template1
    2. {
    3. "template": {
    4. "mappings": {
    5. "properties": {
    6. "@timestamp": {
    7. "type": "date"
    8. }
    9. }
    10. }
    11. }
    12. }
    13. PUT _component_template/other_component_template
    14. {
    15. "template": {
    16. "mappings": {
    17. "properties": {
    18. "ip_address": {
    19. "type": "ip"
    20. }
    21. }
    22. }
    23. }
    24. }
    25. PUT _index_template/template_1
    26. {
    27. "index_patterns": ["te*", "bar*"],
    28. "template": {
    29. "settings": {
    30. "number_of_shards": 1
    31. },
    32. "mappings": {
    33. "properties": {
    34. "host_name": {
    35. "type": "keyword"
    36. },
    37. "created_at": {
    38. "type": "date",
    39. "format": "EEE MMM dd HH:mm:ss Z yyyy"
    40. }
    41. }
    42. },
    43. "aliases": {
    44. "mydata": { }
    45. }
    46. },
    47. "priority": 200,
    48. "composed_of": ["component_template1", "other_component_template"],
    49. "version": 3,
    50. "_meta": {
    51. "description": "my custom"
    52. }
    53. }