Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created March 7, 2013 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadoonet/5106644 to your computer and use it in GitHub Desktop.
Save dadoonet/5106644 to your computer and use it in GitHub Desktop.
Searching with IP address and dates (logs)
curl -XDELETE http://localhost:9200/log/log/
curl -XPUT http://localhost:9200/log/log/_mapping -d '
{
"log" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"ip" : {
"type" : "ip"
},
"username" : {
"type" : "string"
}
}
}
}'
curl -XPUT http://localhost:9200/log/log/1 -d '
{
"username":"login",
"ip":"127.0.0.1",
"date":"2013-03-07"
}'
curl -XPOST http://localhost:9200/log/_refresh
curl -XPOST http://localhost:9200/log/log/_search -d '
{
"query":{
"filtered":{
"query":{
"match_all":{}
},
"filter":{
"and":{
"filters":[
{
"term":{
"ip":"127.0.0.1"
}
},
{
"range":{
"date":{
"from":"2013-03",
"to":"2013-04"
}
}
}
]
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment