Last active
June 9, 2022 05:59
-
-
Save yuwtennis/a75d3491d94c08082900a63725772602 to your computer and use it in GitHub Desktop.
Indexing document using alias endpoint in elasticsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ILM | |
# https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-rollover.html#ilm-rollover-primar-shardsize-ex | |
# rollover in 5 min | |
PUT _ilm/policy/my_policy | |
{ | |
"policy": { | |
"phases": { | |
"hot": { | |
"actions": { | |
"rollover" : { | |
"max_age": "5m" | |
} | |
} | |
} | |
} | |
} | |
} | |
GET _ilm/policy/my_policy | |
# Index with rollover alias | |
# https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-rollover.html#ilm-rollover | |
PUT my-index-000001 | |
{ | |
"settings": { | |
"index.lifecycle.name": "my_policy", | |
"index.lifecycle.rollover_alias": "my_data" | |
}, | |
"aliases": { | |
"my_data": { | |
"is_write_index": true | |
} | |
} | |
} | |
# Index something | |
POST my_data/_doc | |
{ | |
"a_field": "Hello world." | |
} | |
# Wait 5 min and check if it's rollovered | |
GET _cat/aliases?v&s=alias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commands are assuming you are running from kibana dev console