Cet article est également disponible en Français.
Every year, Santa Claus faces the same scaling problem:
billions of children, one magical delivery window, zero margin for error.
For centuries, he ran everything on parchment scrolls, a quill, and one extremely overworked elf. But this year, Santa modernized his entire Naughty-and-Nice operations stack.
Goodbye scrolls.
Goodbye monolithic North Pole database built on hopes and candy canes.
Hello Elasticsearch.
And with great clusters comes great need for… a command line.
Fortunately for him, the elves found a promising CLI on GitHub and built it straight into the sleigh’s onboard computer:
escli-rs
Why Santa needed a proper CLI
Kibana dashboards are great, unless you’re traveling at Mach 8 over Tokyo and really shouldn’t be clicking menu buttons with heavy mittens on.
Santa needed something:
-
fast
-
scriptable
-
mittens-friendly
Enter escli, a proof-of-concept Elasticsearch CLI that supports multiple versions, secure authentication, real shell auto-completion, and enough convenience to save Christmas.
The elves set up Santa’s .env with:
ESCLI_URL=https://northpole.elasticsearch.cluster
ESCLI_API_KEY=ho-ho-ho-secret
A Cluster full of children
With access to the cluster now established, the elves proceeded to add a number of children to it.
{"index": {"_index": "children-of-the-world", "_id": "zoe-8yo-france"}}
{"name": "Zoe", "age": 8, "nice_score": 0.92, "gift_preference": "Lego Friends", "cookie_offerings": 5, "sibling_conflicts": 1}
{"index": {"_index": "children-of-the-world", "_id": "jai-10yo-india"}}
{"name": "Jai", "age": 10, "nice_score": 0.75, "gift_preference": "Cricket bat", "cookie_offerings": 2, "sibling_conflicts": 4}
{"index": {"_index": "children-of-the-world", "_id": "mia-6yo-canada"}}
{"name": "Mia", "age": 6, "nice_score": 0.98, "gift_preference": "Stuffed bear", "cookie_offerings": 10, "sibling_conflicts": 0}
{"index": {"_index": "children-of-the-world", "_id": "lucas-11yo-usa"}}
{"name": "Lucas", "age": 11, "nice_score": 0.33, "gift_preference": "RC car", "cookie_offerings": 1, "sibling_conflicts": 7}
{"index": {"_index": "children-of-the-world", "_id": "sofia-9yo-spain"}}
{"name": "Sofia", "age": 9, "nice_score": 0.87, "gift_preference": "Art supplies", "cookie_offerings": 4, "sibling_conflicts": 2}
escli bulk --refresh wait_for --input children_of_the_world.ndjson
Santa's Elasticsearch setup is good to go with the key essentials:
-
Index:
children-of-the-world -
Fields:
name,age,nice_score,gift_preference,cookie_offerings,sibling_conflicts
And now, thanks to escli, Santa can query it from anywhere on Earth. Even mid-flight.
Real commands Santa actually uses
Get a single child document
escli get children-of-the-world "zoe-8yo-france"
Search the really nice ones
echo '{
"query": {
"range": {
"nice_score": {"gte": 0.9}
}
}
}' | escli search \
--index children-of-the-world | jq
Export the naughty list as a CSV file
echo '{
"query": "FROM children-of-the-world | WHERE nice_score < 0.2"
}' | escli esql query --format csv
To prevent the manual export of the Naughty List from disrupting their December stand-up meetings, the elves finally automated the process.
Fortunately, the list was empty this year, as everyone has been nice.
Auto-completion: Santa’s new favorite feature
One of the coolest features in escli is shell auto-completion.
To install completions:
eval "$(COMPLETE=bash ./escli)"
Now he can type:
escli esql q<TAB>
and his terminal helpfully expands it to:
escli esql query
Even the reindeer are impressed.
Christmas saved by --help
Santa, having to remember a near-infinite number of API options across his vast logistics network, would sometimes forget a flag or two. He wasn't ashamed. He happily used the --help flag to quickly refresh his memory.
escli --help
-
Documented commands.
-
Consistent structure.
-
No surprises.
The elves even resisted the urge to add ASCII art (after a small “terminal meltdown incident”).
Santa scrolled through the help output, smiled, and whispered "This is incredibly useful!" and delivered billions of gifts right on schedule.
If It’s good enough for Santa…
…then maybe it’s good enough for your Elasticsearch cluster too.
Download the latest pre-release build today from the escli-rs repository and try it.
We'd love to hear your feedback: Open an issue on GitHub to let us know what you think!
