Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created Mar 7, 2013
Embed
What would you like to do?
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