Skip to content

Instantly share code, notes, and snippets.

@yuwtennis
Last active June 9, 2022 05:59
Show Gist options
  • Save yuwtennis/a75d3491d94c08082900a63725772602 to your computer and use it in GitHub Desktop.
Save yuwtennis/a75d3491d94c08082900a63725772602 to your computer and use it in GitHub Desktop.
Indexing document using alias endpoint in elasticsearch
# 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
@yuwtennis
Copy link
Author

Commands are assuming you are running from kibana dev console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment