Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Create test index
- curl -XPUT 'http://localhost:9200/ip_test/' -d '{
- "settings" : {
- "index" : {
- "number_of_shards" : 1,
- "number_of_replicas" : 0
- },
- "mappings" : {
- "ip_test" : {
- "properties" : {
- "ip_start" : { "type" : "ip", "index" : "not_analyzed", "doc_values" : false },
- "ip_end" : { "type" : "ip", "index" : "not_analyzed", "doc_values" : false }
- }
- }
- }
- }
- }'
- ## Put range 127.0.0.1 - 127.0.0.255
- curl -XPOST 'http://localhost:9200/ip_test/ip_test' -d '{
- ip_start: "127.0.0.1",
- ip_end: "127.0.0.255"
- }'
- ## Put range 10.0.0.1 - 10.0.0.255
- curl -XPOST 'http://localhost:9200/ip_test/ip_test' -d '{
- ip_start: "10.0.0.1",
- ip_end: "10.0.0.255"
- }'
- ## Search for IP 127.0.0.1 in ranges
- curl -XPOST 'http://localhost:9200/ip_test/_search' -d '{
- "query": {
- "filtered": {
- "filter": [
- {
- "bool": {
- "must": [
- {
- "range": {
- "ip_start": {
- "lte": "127.0.0.1"
- }
- }
- },
- {
- "range": {
- "ip_end": {
- "gte": "127.0.0.1"
- }
- }
- }
- ]
- }
- }
- ]
- }
- }
- }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement