Skip to content

Instantly share code, notes, and snippets.

@eriky
Last active December 10, 2019 09:21
Show Gist options
  • Save eriky/302ba07353357ac77c8b7fad1f17b142 to your computer and use it in GitHub Desktop.
Save eriky/302ba07353357ac77c8b7fad1f17b142 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e -x
tweets=$(cat <<-END
{ "username" : "eriky", "post_date" : "2019-12-08T14:10:12", "message" : "I wrote an article on Elasticsearch" }
{ "username" : "elon", "post_date" : "2019-12-08T14:16:12", "message" : "Anyone needs a flight to Mars? I have seats available." }
{ "username" : "eriky", "post_date" : "2019-12-08T15:10:12", "message" : "@elon Count me in! I love Mars (and Elasticsearch)" }
{ "username" : "kimchy", "post_date" : "2019-12-08T15:30:22", "message" : "@eriky I it too (Elasticsearch, not Mars)" }
END
)
IFS=$'\n'
for tweet in $tweets; do
curl -X POST "localhost:9200/twitter/_doc/?pretty" -H 'Content-Type: application/json' -d "$tweet"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment