Created
March 7, 2013 09:09
-
-
Save dadoonet/5106644 to your computer and use it in GitHub Desktop.
Searching with IP address and dates (logs)
This file contains 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
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