Skip to content

Instantly share code, notes, and snippets.

@kharazi
Created December 6, 2015 14:07
Show Gist options
  • Save kharazi/ab0cb0b8fd87c5ec2935 to your computer and use it in GitHub Desktop.
Save kharazi/ab0cb0b8fd87c5ec2935 to your computer and use it in GitHub Desktop.
curl -XDELETE "http://localhost:9200/test_index"
echo
echo
curl -XPUT "http://localhost:9200/test_index" -d'
{
"mappings": {
"doc": {
"properties": {
"publication_date": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}'
echo
echo
curl -XPOST "http://localhost:9200/test_index/doc/_bulk" -d'
{"index":{"_id":1}}
{"fetched_date":"2015-06-08T06:23:15.664000","publication_date":"2015-06-08T06:12:04.826000","source":"5402af95608395df3fe474dd"}
{"index":{"_id":2}}
{"fetched_date": "2015-02-03T10:52:58.575000", "publication_date": "2015-02-03T10:23:54", "dup": true}
'
curl -XPOST "http://localhost:9200/test_index/_search"
echo
echo
curl -XPOST "http://localhost:9200/test_index/_search" -d'
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"range": {
"publication_date": {
"lte": "2018-12-01",
"gte": "2014-12-02"
}
}
}
}
}
}'
echo
echo
curl -XPOST "http://localhost:9200/test_index/_search" -d'
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"range": {
"publication_date": {
"lte": "2015-05-01",
"gte": "2014-12-02"
}
}
}
}
}
}'
echo
echo
{"acknowledged":true}
{"acknowledged":true}
{"_index":"test_index","_type":"doc","_id":"AVF3miQZXzFtuVrruvYz","_version":1,"created":true}{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
@sloanahrens
Copy link

es2 > curl -XDELETE "http://localhost:9200/test_index"
{"acknowledged":true}es2 > echo

es2 > echo

es2 > curl -XPUT "http://localhost:9200/test_index" -d'
> {
>    "mappings": {
>       "doc": {
>          "properties": {
>             "publication_date": {
>                "type": "date",
>                "format": "dateOptionalTime"
>             }
>          }
>       }
>    }
> }'
{"acknowledged":true}es2 >
es2 > echo

es2 > echo

es2 > curl -XPOST "http://localhost:9200/test_index/doc/_bulk" -d'
> {"index":{"_id":1}}
> {"fetched_date":"2015-06-08T06:23:15.664000","publication_date":"2015-06-08T06:12:04.826000","source":"5402af95608395df3fe474dd"}
> {"index":{"_id":2}}
> {"fetched_date": "2015-02-03T10:52:58.575000", "publication_date": "2015-02-03T10:23:54", "dup": true}
> '
{"took":106,"errors":false,"items":[{"index":{"_index":"test_index","_type":"doc","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"status":201}},{"index":{"_index":"test_index","_type":"doc","_id":"2","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"status":201}}]}es2 > curl -XPOST "http://localhost:9200/test_index/_search"
{"took":17,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"test_index","_type":"doc","_id":"2","_score":1.0,"_source":{"fetched_date": "2015-02-03T10:52:58.575000", "publication_date": "2015-02-03T10:23:54", "dup": true}},{"_index":"test_index","_type":"doc","_id":"1","_score":1.0,"_source":{"fetched_date":"2015-06-08T06:23:15.664000","publication_date":"2015-06-08T06:12:04.826000","source":"5402af95608395df3fe474dd"}}]}}es2 >
es2 >
es2 > curl -XPOST "http://localhost:9200/test_index/_search" -d'
> {
>    "query": {
>       "filtered": {
>          "query": {
>             "match_all": {}
>          },
>          "filter": {
>             "range": {
>                "publication_date": {
>                   "lte": "2018-12-01",
>                   "gte": "2014-12-02"
>                }
>             }
>          }
>       }
>    }
> }'
{"took":33,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"test_index","_type":"doc","_id":"2","_score":1.0,"_source":{"fetched_date": "2015-02-03T10:52:58.575000", "publication_date": "2015-02-03T10:23:54", "dup": true}},{"_index":"test_index","_type":"doc","_id":"1","_score":1.0,"_source":{"fetched_date":"2015-06-08T06:23:15.664000","publication_date":"2015-06-08T06:12:04.826000","source":"5402af95608395df3fe474dd"}}]}}es2 > echo

es2 > echo

es2 >
es2 > curl -XPOST "http://localhost:9200/test_index/_search" -d'
> {
>    "query": {
>       "filtered": {
>          "query": {
>             "match_all": {}
>          },
>          "filter": {
>             "range": {
>                "publication_date": {
>                   "lte": "2015-05-01",
>                   "gte": "2014-12-02"
>                }
>             }
>          }
>       }
>    }
> }'
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"test_index","_type":"doc","_id":"2","_score":1.0,"_source":{"fetched_date": "2015-02-03T10:52:58.575000", "publication_date": "2015-02-03T10:23:54", "dup": true}}]}}es2 >
es2 > echo

es2 > echo

es2 >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment