-
-
Save davidsalazar/6159780 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -n "Deleting ... " | |
curl -XDELETE http://localhost:9200/test_date | |
echo "" | |
echo -n "Create index ... " | |
curl -XPUT http://localhost:9200/test_date | |
echo "" | |
echo -n "Put mapping ... " | |
curl -XPUT http://localhost:9200/test_date/test/_mapping -d ' | |
{ | |
"test":{ | |
"dynamic" : false, | |
"properties":{ | |
"title":{ | |
"type":"string" | |
}, | |
"date":{ | |
"type": "date", | |
"format":"dateOptionalTime" | |
} | |
} | |
} | |
}' | |
echo "" | |
echo "Load documents ... " | |
curl -XPOST http://localhost:9200/test_date/test/7 -d ' | |
{ | |
"title":"Doc 7 : date extended ISO", | |
"date":"2012-07-14T12:30:00" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/8 -d ' | |
{ | |
"title":"Doc 8 : date extended ISO", | |
"date":"2012-08-15T12:30:00" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/9 -d ' | |
{ | |
"title":"Doc 9 : date extended ISO", | |
"date":"2012-09-01T12:30:00" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/4 -d ' | |
{ | |
"title":"Doc 4 : date extended ISO", | |
"date":"2012-04-04" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/5 -d ' | |
{ | |
"title":"Doc 5: date extended ISO", | |
"date":"2012-05-08" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/6 -d ' | |
{ | |
"title":"Doc 6 : date extended ISO", | |
"date":"2012-06-11" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/1 -d ' | |
{ | |
"title":"Doc 1 : date basic ISO", | |
"date":"20120103" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/2 -d ' | |
{ | |
"title":"Doc 2 : date basic ISO", | |
"date":"20120212" | |
} | |
' | |
curl -XPOST http://localhost:9200/test_date/test/3 -d ' | |
{ | |
"title":"Doc 3 : date basic ISO", | |
"date":"20120304" | |
} | |
' | |
echo "" | |
echo "Refresh ..." | |
curl -XPOST http://localhost:9200/test_date/_refresh | |
echo "" | |
echo "Sort and facet by date ..." | |
curl -XPOST http://localhost:9200/test_date/test/_search?pretty=true -d ' | |
{ | |
"query": { | |
"match_all": {} | |
}, | |
"sort": [ | |
{ | |
"date": { | |
"order": "asc" | |
} | |
} | |
], | |
"facets": { | |
"year": { | |
"date_histogram": { | |
"field": "date", | |
"interval": "year" | |
} | |
} | |
} | |
}' | |
echo "" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment