Skip to content

Instantly share code, notes, and snippets.

body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Lets create a big fat mouse icon :)
curl -XPUT "http://localhost:9200/twitter/_mapping" -H 'Content-Type: application/json' -d'
{
"properties": {
"post_time": { "type": "date" },
"username": { "type": "keyword" },
"message": { "type": "text" }
}
}'
curl -X POST "localhost:9200/twitter/_doc/?pretty" -H 'Content-Type: application/json' -d'
{
"user" : "eriky",
"post_date" : "2019-12-08T14:12:12",
"message" : "Who loves Elasticsearch?"
}
'
{
"_index" : "twitter",
"_type" : "_doc",
"_id" : "kZ5G224BweuuP0wE7KiO",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
curl -X PUT "localhost:9200/twitter?pretty" -H 'Content-Type: application/json' -d'
{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}'
#!/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
)
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
curl -X GET "localhost:9200/twitter/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query" : {
"term" : { "username" : "kimchy" }
}
}
'
curl -X GET "localhost:9200/twitter/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"filter": [
{ "term": { "username": "eriky" }},
{ "range": { "post_date": { "lte": "2020-01-01" }}}
]
}
}