Skip to content

Instantly share code, notes, and snippets.

@edwardsmit
Last active April 22, 2016 08:32
Show Gist options
  • Save edwardsmit/43339213ab7779273053613de5bdf26b to your computer and use it in GitHub Desktop.
Save edwardsmit/43339213ab7779273053613de5bdf26b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification/event/_mapping' -d '{
"event": {
"properties": {
"timestamp": {
"type": "date"
}
}
}
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/10' -d '{
"timestamp": "2016-04-22T14:21:00Z"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/11' -d '{
"timestamp": "2016-04-22T14:25:59"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/12' -d '{
"timestamp": "2016-04-22T14:44:00Z"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/13' -d '{
"timestamp": "2016-04-22T14:48:59"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/14' -d '{
"timestamp": "2016-04-23T14:50:00Z"
}'; echo
curl -XPOST 'http://localhost:9200/nowverification/_refresh'; echo
echo
echo "now on full date, aiming for 4 - failing"
curl -XGET "http://localhost:9200/nowverification/_count" -d'
{
"query": {
"range": {
"timestamp": {
"gte": "now",
"lte": "now"
}
}
}
}'; echo
echo
echo "now/d on full date, aiming for 4 - success"
curl -XGET "http://localhost:9200/nowverification/_count" -d'
{
"query": {
"range": {
"timestamp": {
"gte": "now/d",
"lte": "now/d"
}
}
}
}'; echo
curl -XDELETE 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification/event/_mapping' -d '{
"event": {
"properties": {
"timestamp": {
"type": "date",
"format": "date"
}
}
}
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/10' -d '{
"timestamp": "2016-04-22"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/11' -d '{
"timestamp": "2016-04-22"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/12' -d '{
"timestamp": "2016-04-22"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/13' -d '{
"timestamp": "2016-04-22"
}'; echo
curl -XPUT 'localhost:9200/nowverification/event/14' -d '{
"timestamp": "2016-04-23"
}'; echo
curl -XPOST 'http://localhost:9200/nowverification/_refresh'; echo
echo
echo "now on full date, aiming for 4 - failing"
curl -XGET "http://localhost:9200/nowverification/_count" -d'
{
"query": {
"range": {
"timestamp": {
"gte": "now",
"lte": "now"
}
}
}
}'; echo
echo
echo "now/d on full date, aiming for 4 - success"
curl -XGET "http://localhost:9200/nowverification/_count" -d'
{
"query": {
"range": {
"timestamp": {
"gte": "now/d",
"lte": "now/d"
}
}
}
}'; echo
echo "Conclusion: Stored format isn't really a differentiator, it's the format of the query that counts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment