Skip to content

Instantly share code, notes, and snippets.

@bartfastiel
Last active July 20, 2017 15:07
Show Gist options
  • Save bartfastiel/1596358684f42728a957e6dcd21ea686 to your computer and use it in GitHub Desktop.
Save bartfastiel/1596358684f42728a957e6dcd21ea686 to your computer and use it in GitHub Desktop.
echo delete index
curl -XDELETE 'http://127.0.0.1:9200/histos?pretty=1'
echo create index
curl -XPUT 'http://127.0.0.1:9200/histos?pretty=1'
echo create type
curl -XPUT 'http://127.0.0.1:9200/histos/_mapping/histo?pretty=1' -d'{
"properties": {
"issueCreatedAt": {
"type": "date",
"format": "epoch_second"
}
}
}'
echo insert issues
#index {[issues][issue][ISSUE0], source{"issueCreatedAt":1303689913}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE0?pretty=1' -d'{
"issueCreatedAt": 1303689913
}'
#index {[issues][issue][ISSUE1], source{"issueCreatedAt":1409571296}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE1?pretty=1' -d'{
"issueCreatedAt": 1409571296
}'
#index {[issues][issue][ISSUE2], source{"issueCreatedAt":1409611560}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE2?pretty=1' -d'{
"issueCreatedAt": 1409611560
}'
#index {[issues][issue][ISSUE3], source{"issueCreatedAt":1409657696}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE3?pretty=1' -d'{
"issueCreatedAt": 1409657696
}'
#index {[issues][issue][ISSUE4], source{"issueCreatedAt":1409916896}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE4?pretty=1' -d'{
"issueCreatedAt": 1409916896
}'
#index {[issues][issue][ISSUE5], source{"issueCreatedAt":1411212896}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE5?pretty=1' -d'{
"issueCreatedAt": 1411212896
}'
#index {[issues][issue][ISSUE6], source{"issueCreatedAt":1421580896}
curl -XPUT 'http://127.0.0.1:9200/histos/histo/ISSUE6?pretty=1' -d'{
"issueCreatedAt": 1421580896
}'
echo flush
curl -XPOST 'http://127.0.0.1:9200/histos/_flush?pretty=1'
echo search
curl -XGET 'http://127.0.0.1:9200/histos/histo/_search?pretty=1' -d '{
"from" : 0,
"size" : 10,
"query" : {
"bool" : {
"must" : [
{
"match_all" : {
"boost" : 1.0
}
}
],
"filter" : [
{
"bool" : {
"must" : [
{
"range" : {
"issueCreatedAt" : {
"from" : null,
"to" : 1411254000,
"include_lower" : true,
"include_upper" : false,
"boost" : 1.0
}
}
},
{
"range" : {
"issueCreatedAt" : {
"from" : 1409526000,
"to" : null,
"include_lower" : true,
"include_upper" : true,
"boost" : 1.0
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"sort" : [
{
"issueCreatedAt" : {
"order" : "desc",
"missing" : "_first"
}
}
],
"aggregations" : {
"createdAt" : {
"date_histogram" : {
"field" : "issueCreatedAt",
"format" : "yyyy-MM-dd'"'"'T'"'"'HH:mm:ssZ",
"time_zone" : "UTC",
"interval" : "1w",
"offset" : 3600000,
"order" : {
"_key" : "asc"
},
"keyed" : false,
"min_doc_count" : 0,
"extended_bounds" : {
"min" : 1409526000000,
"max" : 1411253999000
}
}
}
},
"ext" : { }
}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment